aliabd HF Staff commited on
Commit
1333a85
Β·
1 Parent(s): d5c6853

Upload with huggingface_hub

Browse files
Files changed (6) hide show
  1. DESCRIPTION.md +1 -0
  2. README.md +6 -7
  3. gongyoo.jpeg +0 -0
  4. groot.jpeg +0 -0
  5. requirements.txt +9 -0
  6. run.py +38 -0
DESCRIPTION.md ADDED
@@ -0,0 +1 @@
 
 
1
+ Recreate the viral AnimeGAN image transformation demo.
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Animeganv2 Main
3
- emoji: πŸ“‰
4
- colorFrom: green
5
- colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.6
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: animeganv2_main
4
+ emoji: πŸ”₯
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.6
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
gongyoo.jpeg ADDED
groot.jpeg ADDED
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ Pillow
4
+ gdown
5
+ numpy
6
+ scipy
7
+ cmake
8
+ onnxruntime-gpu
9
+ opencv-python-headlesshttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import torch
4
+
5
+ model2 = torch.hub.load(
6
+ "AK391/animegan2-pytorch:main",
7
+ "generator",
8
+ pretrained=True,
9
+ progress=False
10
+ )
11
+ model1 = torch.hub.load("AK391/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1")
12
+ face2paint = torch.hub.load(
13
+ 'AK391/animegan2-pytorch:main', 'face2paint',
14
+ size=512,side_by_side=False
15
+ )
16
+
17
+ def inference(img, ver):
18
+ if ver == 'version 2 (πŸ”Ί robustness,πŸ”» stylization)':
19
+ out = face2paint(model2, img)
20
+ else:
21
+ out = face2paint(model1, img)
22
+ return out
23
+
24
+ title = "AnimeGANv2"
25
+ description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."
26
+ article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_animegan' alt='visitor badge'></center></p>"
27
+ examples=[['groot.jpeg','version 2 (πŸ”Ί robustness,πŸ”» stylization)'],['gongyoo.jpeg','version 1 (πŸ”Ί stylization, πŸ”» robustness)']]
28
+
29
+ demo = gr.Interface(
30
+ fn=inference,
31
+ inputs=[gr.inputs.Image(type="pil"),gr.inputs.Radio(['version 1 (πŸ”Ί stylization, πŸ”» robustness)','version 2 (πŸ”Ί robustness,πŸ”» stylization)'], type="value", default='version 2 (πŸ”Ί robustness,πŸ”» stylization)', label='version')],
32
+ outputs=gr.outputs.Image(type="pil"),
33
+ title=title,
34
+ description=description,
35
+ article=article,
36
+ examples=examples)
37
+
38
+ demo.launch()