sanket kheni commited on
Commit
8845f1c
β€’
1 Parent(s): 48447e6
Files changed (5) hide show
  1. LICENSE +21 -0
  2. README.md +8 -9
  3. modules/app.py +40 -0
  4. requirements.txt +5 -0
  5. start.py +3 -0
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,12 +1,11 @@
1
  ---
2
- title: Pwcolor
3
- emoji: πŸš€
4
- colorFrom: yellow
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 3.4.1
8
- app_file: app.py
9
  pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Colorize
3
+ emoji: 🌟
4
+ colorFrom: blue
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.4
8
+ app_file: start.py
9
  pinned: false
10
+ license: mit
11
+ ---
 
modules/app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from typing import Optional
8
+
9
+
10
+ model = hub.Module(name='deoldify')
11
+ # NOTE: Max is 45 with 11GB video cards. 35 is a good default
12
+ render_factor=35
13
+
14
+
15
+ def colorize_image(image):
16
+ # now = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
17
+ if not os.path.exists("./output"):
18
+ os.makedirs("./output")
19
+ # if image is not None:
20
+ # image.save(f"./output/{now}-input.jpg")
21
+ model.predict(image.name)
22
+ return './output/DeOldify/'+Path(image.name).stem+".png"
23
+
24
+
25
+ def create_interface():
26
+ with gr.Blocks() as enhancer:
27
+ gr.Markdown("Colorize old black & white photos")
28
+ with gr.Column(scale=1, label = "Colorize photo", visible=True) as colorize_column:
29
+ colorize_input = gr.Image(type="file")
30
+ colorize_button = gr.Button("Colorize!")
31
+ colorize_output = gr.Image(type="file")
32
+ download_colorize_button = gr.outputs.File(label="Download colorized image!")
33
+ colorize_button.click(colorize_image, inputs=colorize_input, outputs=colorize_output)
34
+ enhancer.launch()
35
+
36
+ def run_code():
37
+ create_interface()
38
+
39
+ # The main function
40
+ run_code()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ paddlepaddle
2
+ paddlehub
3
+ gradio
4
+ fastapi[all]==0.85.*
5
+ uvicorn[standard]==0.18.*
start.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import subprocess
2
+
3
+ subprocess.run("uvicorn modules.app:app --host 0.0.0.0 --port 7860", shell=True)