Spaces:
Runtime error
Runtime error
jaekookang
commited on
Commit
β’
6bf7bb2
1
Parent(s):
caf2f8e
change cv to imageio
Browse files- .gitignore +2 -1
- README.md +13 -0
- gradio_painttransformer.py +11 -11
- requirements.txt +1 -0
.gitignore
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
__pycache__
|
2 |
*.log
|
3 |
*.pdparams
|
4 |
-
*.mp4
|
|
|
|
1 |
__pycache__
|
2 |
*.log
|
3 |
*.pdparams
|
4 |
+
*.mp4
|
5 |
+
*.gif
|
README.md
CHANGED
@@ -8,6 +8,19 @@ app_file: gradio_painttransformer.py
|
|
8 |
pinned: false
|
9 |
---
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Configuration
|
12 |
|
13 |
`title`: _string_
|
|
|
8 |
pinned: false
|
9 |
---
|
10 |
|
11 |
+
- 2021-12-21 first created
|
12 |
+
- opencv error:
|
13 |
+
```
|
14 |
+
Traceback (most recent call last):
|
15 |
+
File "gradio_painttransformer.py", line 12, in <module>
|
16 |
+
import cv2
|
17 |
+
File "/home/user/.local/lib/python3.8/site-packages/cv2/__init__.py", line 8, in <module>
|
18 |
+
from .cv2 import *
|
19 |
+
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
|
20 |
+
```
|
21 |
+
- Instead, using `imageio` make gif file as output
|
22 |
+
|
23 |
+
|
24 |
# Configuration
|
25 |
|
26 |
`title`: _string_
|
gradio_painttransformer.py
CHANGED
@@ -6,10 +6,8 @@
|
|
6 |
'''
|
7 |
|
8 |
import os
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
import cv2
|
13 |
import network
|
14 |
from time import time
|
15 |
from glob import glob
|
@@ -64,23 +62,25 @@ def predict(image_file):
|
|
64 |
final_result_list = render_serial.render_serial(original_img, net_g, meta_brushes)
|
65 |
logger.info(f'--- inference took {time() - t0:.4f} sec')
|
66 |
|
67 |
-
out = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), FPS,
|
68 |
-
|
69 |
for idx, frame in enumerate(final_result_list):
|
70 |
-
out.write(frame)
|
71 |
-
|
|
|
|
|
72 |
logger.info('--- animation generated')
|
73 |
-
return 'output.
|
74 |
|
75 |
iface = gr.Interface(
|
76 |
predict,
|
77 |
title='π¨ Paint Transformer',
|
78 |
-
description='This demo converts an image into a sequence of painted images (
|
79 |
inputs=[
|
80 |
gr.inputs.Image(label='Input image', type='filepath')
|
81 |
],
|
82 |
outputs=[
|
83 |
-
gr.outputs.
|
84 |
],
|
85 |
examples=examples,
|
86 |
article='<p style="text-align:center">Original work: <a href="https://github.com/wzmsltw/PaintTransformer">PaintTransformer</a></p>'
|
|
|
6 |
'''
|
7 |
|
8 |
import os
|
9 |
+
# import cv2 # <== error
|
10 |
+
import imageio
|
|
|
|
|
11 |
import network
|
12 |
from time import time
|
13 |
from glob import glob
|
|
|
62 |
final_result_list = render_serial.render_serial(original_img, net_g, meta_brushes)
|
63 |
logger.info(f'--- inference took {time() - t0:.4f} sec')
|
64 |
|
65 |
+
# out = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), FPS, (WIDTH, HEIGHT))
|
66 |
+
frames = []
|
67 |
for idx, frame in enumerate(final_result_list):
|
68 |
+
# out.write(frame)
|
69 |
+
frames.append(frame)
|
70 |
+
# out.release()
|
71 |
+
imageio.mimsave('output.gif', frames, mode="RGBA")
|
72 |
logger.info('--- animation generated')
|
73 |
+
return 'output.gif'
|
74 |
|
75 |
iface = gr.Interface(
|
76 |
predict,
|
77 |
title='π¨ Paint Transformer',
|
78 |
+
description='This demo converts an image into a sequence of painted images (takes about 90 sec)',
|
79 |
inputs=[
|
80 |
gr.inputs.Image(label='Input image', type='filepath')
|
81 |
],
|
82 |
outputs=[
|
83 |
+
gr.outputs.Image(label='Output animation')
|
84 |
],
|
85 |
examples=examples,
|
86 |
article='<p style="text-align:center">Original work: <a href="https://github.com/wzmsltw/PaintTransformer">PaintTransformer</a></p>'
|
requirements.txt
CHANGED
@@ -5,4 +5,5 @@ torch
|
|
5 |
gradio
|
6 |
Pillow
|
7 |
opencv-python
|
|
|
8 |
paddlepaddle==2.2.1
|
|
|
5 |
gradio
|
6 |
Pillow
|
7 |
opencv-python
|
8 |
+
imageio
|
9 |
paddlepaddle==2.2.1
|