Spaces:
Runtime error
Runtime error
Download app.py from guney/photo-with-code: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/guney/photo-with-code/resolve/main/app.py
- Command line
-
hf download hf://spaces/guney/photo-with-code/app.py
-
curl -L -o app.py https://huggingface.co/spaces/guney/photo-with-code/resolve/main/app.py
1.4 kB
| import gradio as gr | |
| from photowithcode import * | |
| def type2im(type): | |
| path = f'code_images/{type}.png' | |
| return cv2.imread(path, cv2.IMREAD_COLOR) | |
| def imgproc_1(photo, type, mirror_code): | |
| print(type) | |
| code = type2im(type) | |
| out = photowithcode_proc(photo, code, True, mirror_code) | |
| return out | |
| def imgproc_2(photo, code, dim_background, mirror_code): | |
| out = photowithcode_proc(photo, code, dim_background, mirror_code) | |
| return out | |
| with gr.Blocks() as demo: | |
| gr.Markdown('Overlay your code on to you photo with this demo.') | |
| with gr.Tab('Use existing code'): | |
| with gr.Row(): | |
| with gr.Column(): | |
| input_1 = [gr.Image(), gr.Radio(['Rust', 'C++', 'Python'], value='Rust', label='Choose your programming language'), gr.Checkbox(label='Mirror the code?')] | |
| with gr.Column(): | |
| output_1 = gr.Image() | |
| button_1 = gr.Button('Submit') | |
| with gr.Tab('Use your own code'): | |
| with gr.Row(): | |
| with gr.Column(): | |
| input_2 = [gr.Image(), gr.Image(), gr.Checkbox(label='Dim the code background?'), gr.Checkbox(label='Mirror the code?')] | |
| with gr.Column(): | |
| output_2 = gr.Image() | |
| button_2 = gr.Button('Submit') | |
| button_1.click(imgproc_1, inputs=input_1, outputs=output_1) | |
| button_2.click(imgproc_2, inputs=input_2, outputs=output_2) | |
| demo.launch() |