zhenwusw commited on
Commit
de9ffce
·
1 Parent(s): 76f4227
Files changed (13) hide show
  1. IU.png +0 -0
  2. README.md +13 -21
  3. app.py +33 -0
  4. beyonce.jpeg +0 -0
  5. beyonce.png +0 -0
  6. bill.png +0 -0
  7. billie.png +0 -0
  8. elon.png +0 -0
  9. gongyoo.jpeg +0 -0
  10. groot.jpeg +0 -0
  11. requirements.txt +9 -0
  12. tony.png +0 -0
  13. will.png +0 -0
IU.png ADDED
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: AnimeGAN
3
  emoji: ⚡
4
- colorFrom: green
5
- colorTo: green
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: false
@@ -10,36 +10,28 @@ pinned: false
10
 
11
  # Configuration
12
 
13
- `title`: _string_
14
  Display title for the Space
15
 
16
- `emoji`: _string_
17
  Space emoji (emoji-only character allowed)
18
 
19
- `colorFrom`: _string_
20
  Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
21
 
22
- `colorTo`: _string_
23
  Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
24
 
25
- `sdk`: _string_
26
- Can be either `gradio`, `streamlit`, or `static`
27
 
28
- `sdk_version` : _string_
29
  Only applicable for `streamlit` SDK.
30
  See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
31
 
32
- `app_file`: _string_
33
- Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
34
  Path is relative to the root of the repository.
35
 
36
- `models`: _List[string]_
37
- HF model IDs (like "gpt2" or "deepset/roberta-base-squad2") used in the Space.
38
- Will be parsed automatically from your code if not specified here.
39
-
40
- `datasets`: _List[string]_
41
- HF dataset IDs (like "common_voice" or "oscar-corpus/OSCAR-2109") used in the Space.
42
- Will be parsed automatically from your code if not specified here.
43
-
44
- `pinned`: _boolean_
45
  Whether the Space stays on top of your list.
 
1
  ---
2
+ title: AnimeGANv2
3
  emoji: ⚡
4
+ colorFrom: yellow
5
+ colorTo: blue
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: false
 
10
 
11
  # Configuration
12
 
13
+ `title`: _string_
14
  Display title for the Space
15
 
16
+ `emoji`: _string_
17
  Space emoji (emoji-only character allowed)
18
 
19
+ `colorFrom`: _string_
20
  Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
21
 
22
+ `colorTo`: _string_
23
  Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
24
 
25
+ `sdk`: _string_
26
+ Can be either `gradio` or `streamlit`
27
 
28
+ `sdk_version` : _string_
29
  Only applicable for `streamlit` SDK.
30
  See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
31
 
32
+ `app_file`: _string_
33
+ Path to your main application file (which contains either `gradio` or `streamlit` Python code).
34
  Path is relative to the root of the repository.
35
 
36
+ `pinned`: _boolean_
 
 
 
 
 
 
 
 
37
  Whether the Space stays on top of your list.
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from PIL import Image
3
+ import torch
4
+ import gradio as gr
5
+ os.system("pip install gradio==2.5.3")
6
+
7
+ model2 = torch.hub.load(
8
+ "AK391/animegan2-pytorch:main",
9
+ "generator",
10
+ pretrained=True,
11
+ device="cuda",
12
+ progress=False
13
+ )
14
+
15
+
16
+ model1 = torch.hub.load("AK391/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1", device="cuda")
17
+ face2paint = torch.hub.load(
18
+ 'AK391/animegan2-pytorch:main', 'face2paint',
19
+ size=512, device="cuda",side_by_side=False
20
+ )
21
+ def inference(img, ver):
22
+ if ver == 'version 2 (🔺 robustness,🔻 stylization)':
23
+ out = face2paint(model2, img)
24
+ else:
25
+ out = face2paint(model1, img)
26
+ return out
27
+
28
+ title = "AnimeGANv2"
29
+ 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."
30
+ 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 style='text-align: center'>samples from repo: <img src='https://user-images.githubusercontent.com/26464535/129888683-98bb6283-7bb8-4d1a-a04a-e795f5858dcf.gif' alt='animation'/> <img src='https://user-images.githubusercontent.com/26464535/137619176-59620b59-4e20-4d98-9559-a424f86b7f24.jpg' alt='animation'/><img src='https://user-images.githubusercontent.com/26464535/127134790-93595da2-4f8b-4aca-a9d7-98699c5e6914.jpg' alt='animation'/></p>"
31
+ examples=[['groot.jpeg','version 2 (🔺 robustness,🔻 stylization)'],['bill.png','version 1 (🔺 stylization, 🔻 robustness)'],['tony.png','version 1 (🔺 stylization, 🔻 robustness)'],['elon.png','version 2 (🔺 robustness,🔻 stylization)'],['IU.png','version 1 (🔺 stylization, 🔻 robustness)'],['billie.png','version 2 (🔺 robustness,🔻 stylization)'],['will.png','version 2 (🔺 robustness,🔻 stylization)'],['beyonce.png','version 1 (🔺 stylization, 🔻 robustness)'],['gongyoo.jpeg','version 1 (🔺 stylization, 🔻 robustness)']]
32
+ gr.Interface(inference, [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')
33
+ ], gr.outputs.Image(type="pil"),title=title,description=description,article=article,examples=examples,allow_flagging=False,enable_queue=True).launch()
beyonce.jpeg ADDED
beyonce.png ADDED
bill.png ADDED
billie.png ADDED
elon.png ADDED
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-headless
tony.png ADDED
will.png ADDED