Spaces:
Runtime error
Runtime error
senior-sigan
commited on
Commit
β’
c3ff101
1
Parent(s):
33e4186
update dependenices and fix deprecation warnings
Browse files- README.md +13 -2
- app.py +7 -6
- generator.py +0 -1
- requirements.txt +9 -6
README.md
CHANGED
@@ -4,10 +4,21 @@ emoji: π
|
|
4 |
colorFrom: blue
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
11 |
---
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.17.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
+
python_version: 3.8.9
|
12 |
---
|
13 |
|
14 |
+
Photos stylisation using deep neural networks: anime and art style.
|
15 |
+
|
16 |
+
Read more at [7bits.it/portfolio/nijigenka-ai](https://7bits.it/portfolio/nijigenka-ai).
|
17 |
+
|
18 |
+
## Local development
|
19 |
+
|
20 |
+
Install gradio `pip install gradio==3.17.1`.
|
21 |
+
|
22 |
+
Install other deps: `pip install -r requirements.txt`.
|
23 |
+
|
24 |
+
Run application `python app.py --models_repo_id=/path/to/dir/with/models`. You can ommit `--models_repo_id` if you would like to download models from the hugging face hub.
|
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import argparse
|
2 |
-
from cProfile import label
|
3 |
import functools
|
4 |
import pathlib
|
5 |
import os
|
@@ -42,6 +41,7 @@ def join_image_h(im1: PIL.Image.Image, im2: PIL.Image.Image) -> PIL.Image.Image:
|
|
42 |
def predict(
|
43 |
image: PIL.Image.Image,
|
44 |
style: str,
|
|
|
45 |
face_aligner: FaceAligner,
|
46 |
encoder: Encoder,
|
47 |
generator: Dict[str, Generator],
|
@@ -65,6 +65,7 @@ def predict(
|
|
65 |
def get_model_path(repo_id: str, filename: str):
|
66 |
maybe_path = os.path.join(repo_id, filename)
|
67 |
if os.path.exists(maybe_path):
|
|
|
68 |
return os.path.abspath(maybe_path)
|
69 |
else:
|
70 |
return hf_hub_download(
|
@@ -120,20 +121,20 @@ def main():
|
|
120 |
iface = gr.Interface(
|
121 |
fn=func,
|
122 |
inputs=[
|
123 |
-
gr.
|
124 |
type='pil',
|
125 |
label='Real photo with a face',
|
126 |
),
|
127 |
-
gr.
|
128 |
choices=generator_types,
|
129 |
type='value',
|
130 |
-
|
131 |
label='Style',
|
132 |
),
|
133 |
],
|
134 |
outputs=[
|
135 |
-
gr.
|
136 |
-
gr.
|
137 |
],
|
138 |
examples=load_examples(),
|
139 |
title='Nijigenka: Portrait to Art',
|
|
|
1 |
import argparse
|
|
|
2 |
import functools
|
3 |
import pathlib
|
4 |
import os
|
|
|
41 |
def predict(
|
42 |
image: PIL.Image.Image,
|
43 |
style: str,
|
44 |
+
*,
|
45 |
face_aligner: FaceAligner,
|
46 |
encoder: Encoder,
|
47 |
generator: Dict[str, Generator],
|
|
|
65 |
def get_model_path(repo_id: str, filename: str):
|
66 |
maybe_path = os.path.join(repo_id, filename)
|
67 |
if os.path.exists(maybe_path):
|
68 |
+
print('Using local models')
|
69 |
return os.path.abspath(maybe_path)
|
70 |
else:
|
71 |
return hf_hub_download(
|
|
|
121 |
iface = gr.Interface(
|
122 |
fn=func,
|
123 |
inputs=[
|
124 |
+
gr.Image(
|
125 |
type='pil',
|
126 |
label='Real photo with a face',
|
127 |
),
|
128 |
+
gr.Radio(
|
129 |
choices=generator_types,
|
130 |
type='value',
|
131 |
+
value=generator_types[0],
|
132 |
label='Style',
|
133 |
),
|
134 |
],
|
135 |
outputs=[
|
136 |
+
gr.Gallery(label='Result'),
|
137 |
+
gr.Textbox(label='Error'),
|
138 |
],
|
139 |
examples=load_examples(),
|
140 |
title='Nijigenka: Portrait to Art',
|
generator.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
from xml.etree.ElementTree import PI
|
2 |
import PIL.Image
|
3 |
import onnxruntime
|
4 |
import numpy as np
|
|
|
|
|
1 |
import PIL.Image
|
2 |
import onnxruntime
|
3 |
import numpy as np
|
requirements.txt
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
-
huggingface-hub==0.
|
2 |
-
pillow==
|
3 |
-
numpy==1.
|
4 |
-
onnxruntime==1.
|
5 |
-
dlib==19.
|
6 |
-
scipy==1.
|
|
|
|
|
|
|
|
1 |
+
huggingface-hub==0.12.0
|
2 |
+
pillow==9.4.0
|
3 |
+
numpy==1.24.1
|
4 |
+
onnxruntime==1.13.1
|
5 |
+
dlib==19.24.0
|
6 |
+
scipy==1.10.0
|
7 |
+
|
8 |
+
# for local dev
|
9 |
+
# gradio==3.17.1
|