Spaces:
Running
Running
added gradio_imageslider (#1)
Browse files- added gradio_imageslider (c0377675a5ef104c350dbaa1c00bff53a0eda1a5)
- added gradio_imageslider component as output (5712a94b116c4c0a82fba43d9322ef81b79f5438)
Co-authored-by: yuvraj sharma <ysharma@users.noreply.huggingface.co>
- app.py +8 -3
- requirements.txt +2 -1
app.py
CHANGED
@@ -6,6 +6,8 @@ from modelscope.pipelines import pipeline
|
|
6 |
from modelscope.utils.constant import Tasks
|
7 |
import PIL
|
8 |
import numpy as np
|
|
|
|
|
9 |
|
10 |
img_colorization = pipeline(Tasks.image_colorization, model='iic/cv_ddcolor_image-colorization')
|
11 |
img_path = 'input.png'
|
@@ -15,15 +17,18 @@ def color(image):
|
|
15 |
output = img_colorization(image[...,::-1])
|
16 |
result = output[OutputKeys.OUTPUT_IMG].astype(np.uint8)
|
17 |
result = result[...,::-1]
|
|
|
|
|
|
|
18 |
print('infer finished!')
|
19 |
-
return
|
20 |
-
|
21 |
|
22 |
title = "old_photo_restoration"
|
23 |
description = "upload old photo, ddcolor image colorization"
|
24 |
examples = [['./input.jpg'],]
|
25 |
|
26 |
-
demo = gr.Interface(fn=color,inputs="image",outputs=
|
27 |
|
28 |
if __name__ == "__main__":
|
29 |
demo.launch(share=False)
|
|
|
6 |
from modelscope.utils.constant import Tasks
|
7 |
import PIL
|
8 |
import numpy as np
|
9 |
+
import uuid
|
10 |
+
from gradio_imageslider import ImageSlider
|
11 |
|
12 |
img_colorization = pipeline(Tasks.image_colorization, model='iic/cv_ddcolor_image-colorization')
|
13 |
img_path = 'input.png'
|
|
|
17 |
output = img_colorization(image[...,::-1])
|
18 |
result = output[OutputKeys.OUTPUT_IMG].astype(np.uint8)
|
19 |
result = result[...,::-1]
|
20 |
+
# Generate a unique filename using UUID
|
21 |
+
unique_imgfilename = str(uuid.uuid4()) + '.png'
|
22 |
+
cv2.imwrite(unique_imgfilename, result)
|
23 |
print('infer finished!')
|
24 |
+
return (image, unique_imgfilename)
|
25 |
+
|
26 |
|
27 |
title = "old_photo_restoration"
|
28 |
description = "upload old photo, ddcolor image colorization"
|
29 |
examples = [['./input.jpg'],]
|
30 |
|
31 |
+
demo = gr.Interface(fn=color,inputs="image",outputs=ImageSlider(position=0.5,label='Colored image with slider-view'),examples=examples,title=title,description=description)
|
32 |
|
33 |
if __name__ == "__main__":
|
34 |
demo.launch(share=False)
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
gradio
|
|
|
|
1 |
+
gradio
|
2 |
+
gradio_imageslider
|