Spaces:
Runtime error
Runtime error
Ajay Harikumar
commited on
Commit
·
4dd5454
1
Parent(s):
f361478
Add app, requirements and license
Browse files
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2022 Ajay
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,13 +1,2 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
emoji: 💩
|
4 |
-
colorFrom: blue
|
5 |
-
colorTo: purple
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.4
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: mit
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# deoldify_colorizer
|
2 |
+
Colorizer is a Gradio program based on Deoldify (https://github.com/jantic/DeOldify)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system("hub install deoldify==1.0.1")
|
3 |
+
import gradio as gr
|
4 |
+
import paddlehub as hub
|
5 |
+
from pathlib import Path
|
6 |
+
from datetime import datetime
|
7 |
+
|
8 |
+
model = hub.Module(name='deoldify')
|
9 |
+
# NOTE: Max is 45 with 11GB video cards. 35 is a good default
|
10 |
+
render_factor=35
|
11 |
+
|
12 |
+
|
13 |
+
def colorize_image(image):
|
14 |
+
# now = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
|
15 |
+
# if not os.path.exists("./output"):
|
16 |
+
# os.makedirs("./output")
|
17 |
+
# if image is not None:
|
18 |
+
# image.convert("RGB").save(f"./output/{now}-input.jpg")
|
19 |
+
model.predict(image.name)
|
20 |
+
return './output/DeOldify/'+Path(image.name).stem+".png"
|
21 |
+
|
22 |
+
|
23 |
+
def create_interface():
|
24 |
+
with gr.Blocks() as enhancer:
|
25 |
+
gr.Markdown("Colorize old black & white photos")
|
26 |
+
with gr.Column(scale=1, label = "Colorize photo", visible=True) as colorize_column:
|
27 |
+
colorize_input = gr.Image(type="pil")
|
28 |
+
colorize_button = gr.Button("Colorize!")
|
29 |
+
colorize_output = gr.Image(type="pil")
|
30 |
+
download_colorize_button = gr.outputs.File(label="Download colorized image!")
|
31 |
+
colorize_button.click(colorize_image, inputs=colorize_input, outputs=colorize_output)
|
32 |
+
enhancer.launch()
|
33 |
+
|
34 |
+
def run_code():
|
35 |
+
create_interface()
|
36 |
+
|
37 |
+
# The main function
|
38 |
+
run_code()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
paddlepaddle
|
2 |
+
paddlehub
|
3 |
+
gradio
|