init space
Browse files- .gitignore +3 -0
- app.py +57 -0
- delf.py +0 -0
- examples/image_a/01.jpg +3 -0
- examples/image_a/02.jpg +3 -0
- examples/image_a/03.jpg +3 -0
- examples/image_a/04.jpg +3 -0
- examples/image_b/01.jpg +3 -0
- examples/image_b/02.jpg +3 -0
- examples/image_b/03.jpg +3 -0
- examples/image_b/04.jpg +3 -0
- requirements.txt +3 -0
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.idea/
|
| 2 |
+
__pycache__/
|
| 3 |
+
get.py
|
app.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from style_transfer import StyleTransfer
|
| 3 |
+
|
| 4 |
+
style = StyleTransfer()
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def predict(content_image, style_image):
|
| 8 |
+
return style.transfer(content_image, style_image)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
footer = r"""
|
| 12 |
+
<center>
|
| 13 |
+
<b>
|
| 14 |
+
Demo for <a href='https://www.tensorflow.org/hub/tutorials/tf2_arbitrary_image_stylization'>Style Transfer</a>
|
| 15 |
+
</b>
|
| 16 |
+
</center>
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
coffe = r"""
|
| 20 |
+
<center>
|
| 21 |
+
<a href="https://www.buymeacoffee.com/leonelhs"> <img
|
| 22 |
+
src="https://img.buymeacoffee.com/button-api/?text=Buy me a
|
| 23 |
+
coffee&emoji=&slug=leonelhs&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000
|
| 24 |
+
&coffee_colour=ffffff" /></a>
|
| 25 |
+
</center>
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
with gr.Blocks(title="Style Transfer") as app:
|
| 29 |
+
gr.HTML("<center><h1>Style Transfer</h1></center>")
|
| 30 |
+
gr.HTML("<center><h3>Fast Style Transfer for Arbitrary Styles</h3></center>")
|
| 31 |
+
with gr.Row(equal_height=False):
|
| 32 |
+
with gr.Column():
|
| 33 |
+
content_img = gr.Image(type="filepath", label="Content image")
|
| 34 |
+
style_img = gr.Image(type="filepath", label="Style image")
|
| 35 |
+
run_btn = gr.Button(variant="primary")
|
| 36 |
+
with gr.Column():
|
| 37 |
+
output_img = gr.Image(type="pil", label="Output image")
|
| 38 |
+
gr.ClearButton(components=[content_img, style_img, output_img], variant="stop")
|
| 39 |
+
|
| 40 |
+
run_btn.click(predict, [content_img, style_img], [output_img])
|
| 41 |
+
|
| 42 |
+
with gr.Row():
|
| 43 |
+
blobs_c = [[f"examples/contents/{x:02d}.jpg"] for x in range(1, 4)]
|
| 44 |
+
examples_c = gr.Dataset(components=[content_img], samples=blobs_c)
|
| 45 |
+
examples_c.click(lambda x: x[0], [examples_c], [content_img])
|
| 46 |
+
with gr.Row():
|
| 47 |
+
blobs_s = [[f"examples/styles/{x:02d}.jpg"] for x in range(1, 12)]
|
| 48 |
+
examples_s = gr.Dataset(components=[style_img], samples=blobs_s)
|
| 49 |
+
examples_s.click(lambda x: x[0], [examples_s], [style_img])
|
| 50 |
+
|
| 51 |
+
with gr.Row():
|
| 52 |
+
gr.HTML(footer)
|
| 53 |
+
with gr.Row():
|
| 54 |
+
gr.HTML(coffe)
|
| 55 |
+
|
| 56 |
+
app.launch(share=False, debug=True, show_error=True)
|
| 57 |
+
app.queue()
|
delf.py
ADDED
|
File without changes
|
examples/image_a/01.jpg
ADDED
|
Git LFS Details
|
examples/image_a/02.jpg
ADDED
|
Git LFS Details
|
examples/image_a/03.jpg
ADDED
|
Git LFS Details
|
examples/image_a/04.jpg
ADDED
|
Git LFS Details
|
examples/image_b/01.jpg
ADDED
|
Git LFS Details
|
examples/image_b/02.jpg
ADDED
|
Git LFS Details
|
examples/image_b/03.jpg
ADDED
|
Git LFS Details
|
examples/image_b/04.jpg
ADDED
|
Git LFS Details
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pillow>=10.0.1
|
| 2 |
+
numpy>=1.23.5
|
| 3 |
+
tensorflow>=2.15.0
|