Spaces:
Runtime error
Runtime error
bram-w
commited on
Commit
·
cb1cb75
1
Parent(s):
1a4ea1a
copy local version so can modify app.py with requests
Browse files- local_app.py +33 -0
local_app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
from edict_functions import EDICT_editing
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
def greet(name):
|
| 7 |
+
return "Hello " + name + "!!"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def edict(x, source_text, edit_text,
|
| 11 |
+
edit_strength, guidance_scale,
|
| 12 |
+
steps=50, mix_weight=0.93, ):
|
| 13 |
+
x = Image.fromarray(x)
|
| 14 |
+
return_im = EDICT_editing(x,
|
| 15 |
+
source_text,
|
| 16 |
+
edit_text,
|
| 17 |
+
steps=steps,
|
| 18 |
+
mix_weight=mix_weight,
|
| 19 |
+
init_image_strength=edit_strength,
|
| 20 |
+
guidance_scale=guidance_scale
|
| 21 |
+
)[0]
|
| 22 |
+
return np.array(return_im)
|
| 23 |
+
|
| 24 |
+
iface = gr.Interface(fn=edict, inputs=["image",
|
| 25 |
+
gr.Textbox(label="Original Description"),
|
| 26 |
+
gr.Textbox(label="Edit Description"),
|
| 27 |
+
# 50, # gr.Slider(5, 50, value=20, step=1),
|
| 28 |
+
# 0.93, # gr.Slider(0.5, 1, value=0.7, step=0.05),
|
| 29 |
+
gr.Slider(0.0, 1, value=0.8, step=0.05),
|
| 30 |
+
gr.Slider(0, 10, value=3, step=0.5),
|
| 31 |
+
],
|
| 32 |
+
outputs="image")
|
| 33 |
+
iface.launch()
|