Spaces:
Build error
Build error
Podtekatel
commited on
Commit
•
86279bb
1
Parent(s):
c974deb
Update to V2 version
Browse files- app.py +12 -27
- demo/IMG1.jpg +0 -0
- demo/IMG2.jpg +0 -0
- demo/IMG3.jpg +0 -0
- demo/IMG4.jpg +0 -0
- demo/gates.png +0 -0
- demo/jack_sparrow.jpeg +0 -0
- demo/kianu.jpg +0 -0
- demo/squid_game.jpeg +0 -0
app.py
CHANGED
@@ -15,17 +15,14 @@ logging.basicConfig(
|
|
15 |
level=logging.INFO,
|
16 |
datefmt='%Y-%m-%d %H:%M:%S')
|
17 |
|
18 |
-
MODEL_IMG_SIZE =
|
19 |
-
usage_count =
|
20 |
def load_model():
|
21 |
-
REPO_ID = "Podtekatel/
|
22 |
-
FILENAME_OLD = "
|
23 |
-
FILENAME_NEW = "arcane_exp_206_ep_138.onnx"
|
24 |
|
25 |
global model_old
|
26 |
-
global model_new
|
27 |
global pipeline_old
|
28 |
-
global pipeline_new
|
29 |
|
30 |
# Old model
|
31 |
model_path = cached_download(
|
@@ -35,24 +32,12 @@ def load_model():
|
|
35 |
|
36 |
pipeline_old = VSNetModelPipeline(model_old, StatRetinaFaceDetector(MODEL_IMG_SIZE), background_resize=1024, no_detected_resize=1024)
|
37 |
|
38 |
-
|
39 |
-
model_path = cached_download(
|
40 |
-
hf_hub_url(REPO_ID, FILENAME_NEW), use_auth_token=os.getenv('HF_TOKEN')
|
41 |
-
)
|
42 |
-
model_new = ONNXModel(model_path)
|
43 |
-
|
44 |
-
pipeline_new = VSNetModelPipeline(model_new, StatRetinaFaceDetector(MODEL_IMG_SIZE), background_resize=1024,
|
45 |
-
no_detected_resize=1024)
|
46 |
-
|
47 |
-
return model_old, model_new
|
48 |
load_model()
|
49 |
|
50 |
-
def inference(img
|
51 |
img = np.array(img)
|
52 |
-
|
53 |
-
out_img = pipeline_new(img)
|
54 |
-
else:
|
55 |
-
out_img = pipeline_old(img)
|
56 |
|
57 |
out_img = Image.fromarray(out_img)
|
58 |
global usage_count
|
@@ -61,23 +46,23 @@ def inference(img, ver):
|
|
61 |
return out_img
|
62 |
|
63 |
|
64 |
-
title = "
|
65 |
description = "Gradio Demo for Arcane Season 1 style transfer. To use it, simply upload your image, or click one of the examples to load them. Press ❤️ if you like this space!"
|
66 |
article = "This is one of my successful experiments on style transfer. I've built my own pipeline, generator model and private dataset to train this model<br>" \
|
67 |
"" \
|
68 |
"" \
|
69 |
"" \
|
70 |
"Model pipeline which used in project is improved CartoonGAN.<br>" \
|
71 |
-
"This model was trained on RTX 2080 Ti
|
72 |
-
"Model weights
|
73 |
"If you want to use this app or integrate this model into yours, please contact me at email '[email protected]'."
|
74 |
|
75 |
imgs_folder = 'demo'
|
76 |
-
examples = [[os.path.join(imgs_folder, img_filename)
|
77 |
|
78 |
demo = gr.Interface(
|
79 |
fn=inference,
|
80 |
-
inputs=[gr.inputs.Image(type="pil")
|
81 |
outputs=gr.outputs.Image(type="pil"),
|
82 |
title=title,
|
83 |
description=description,
|
|
|
15 |
level=logging.INFO,
|
16 |
datefmt='%Y-%m-%d %H:%M:%S')
|
17 |
|
18 |
+
MODEL_IMG_SIZE = 512
|
19 |
+
usage_count = 0 # Based on hugging face logs
|
20 |
def load_model():
|
21 |
+
REPO_ID = "Podtekatel/ArcaneVSK2"
|
22 |
+
FILENAME_OLD = "arcane_exp_228_ep_159_512_res_V2.onnx"
|
|
|
23 |
|
24 |
global model_old
|
|
|
25 |
global pipeline_old
|
|
|
26 |
|
27 |
# Old model
|
28 |
model_path = cached_download(
|
|
|
32 |
|
33 |
pipeline_old = VSNetModelPipeline(model_old, StatRetinaFaceDetector(MODEL_IMG_SIZE), background_resize=1024, no_detected_resize=1024)
|
34 |
|
35 |
+
return model_old
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
load_model()
|
37 |
|
38 |
+
def inference(img):
|
39 |
img = np.array(img)
|
40 |
+
out_img = pipeline_old(img)
|
|
|
|
|
|
|
41 |
|
42 |
out_img = Image.fromarray(out_img)
|
43 |
global usage_count
|
|
|
46 |
return out_img
|
47 |
|
48 |
|
49 |
+
title = "ARCNStyleTransferV2"
|
50 |
description = "Gradio Demo for Arcane Season 1 style transfer. To use it, simply upload your image, or click one of the examples to load them. Press ❤️ if you like this space!"
|
51 |
article = "This is one of my successful experiments on style transfer. I've built my own pipeline, generator model and private dataset to train this model<br>" \
|
52 |
"" \
|
53 |
"" \
|
54 |
"" \
|
55 |
"Model pipeline which used in project is improved CartoonGAN.<br>" \
|
56 |
+
"This model was trained on RTX 2080 Ti 3 days with batch size 7.<br>" \
|
57 |
+
"Model weights 80 MB in ONNX fp32 format, infers 100 ms on GPU and 600 ms on CPU at 512x512 resolution.<br>" \
|
58 |
"If you want to use this app or integrate this model into yours, please contact me at email '[email protected]'."
|
59 |
|
60 |
imgs_folder = 'demo'
|
61 |
+
examples = [[os.path.join(imgs_folder, img_filename)] for img_filename in sorted(os.listdir(imgs_folder))]
|
62 |
|
63 |
demo = gr.Interface(
|
64 |
fn=inference,
|
65 |
+
inputs=[gr.inputs.Image(type="pil")],
|
66 |
outputs=gr.outputs.Image(type="pil"),
|
67 |
title=title,
|
68 |
description=description,
|
demo/IMG1.jpg
DELETED
Binary file (276 kB)
|
|
demo/IMG2.jpg
DELETED
Binary file (71.5 kB)
|
|
demo/IMG3.jpg
DELETED
Binary file (223 kB)
|
|
demo/IMG4.jpg
DELETED
Binary file (28.6 kB)
|
|
demo/gates.png
ADDED
demo/jack_sparrow.jpeg
ADDED
demo/kianu.jpg
ADDED
demo/squid_game.jpeg
ADDED