Joabutt commited on
Commit
2f31e45
1 Parent(s): cc6d8b8

inital commit

Browse files
Files changed (3) hide show
  1. README.md +5 -7
  2. app.py +38 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,13 +1,11 @@
1
  ---
2
  title: Colourizer
3
- emoji: 🌖
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 3.4
8
  app_file: app.py
9
  pinned: false
10
- license: wtfpl
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Colourizer
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
+ ---
 
 
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.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="file")
28
+ colorize_button = gr.Button("Colorize!")
29
+ colorize_output = gr.Image(type="file")
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