Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -95,6 +95,12 @@ css="""
|
|
95 |
}
|
96 |
"""
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
if torch.cuda.is_available():
|
99 |
power_device = "GPU"
|
100 |
else:
|
@@ -103,8 +109,7 @@ else:
|
|
103 |
def limiter(txt):
|
104 |
return txt[:38]
|
105 |
|
106 |
-
with gr.Blocks(theme=gr.themes.Soft(),css=css) as demo:
|
107 |
-
prompt_value = gr.State("")
|
108 |
with gr.Column(elem_id="col-container"):
|
109 |
gr.Markdown(f"""
|
110 |
# Image Generator
|
@@ -112,7 +117,7 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css) as demo:
|
|
112 |
""")
|
113 |
with gr.Row():
|
114 |
prompt = gr.Textbox(
|
115 |
-
|
116 |
placeholder="Describe the photo",
|
117 |
container=False,
|
118 |
rtl=True,
|
@@ -121,12 +126,6 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css) as demo:
|
|
121 |
with gr.Row():
|
122 |
run_button = gr.Button("Run")
|
123 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
124 |
-
prompt_value.change(
|
125 |
-
fn = limiter,
|
126 |
-
inputs = [prompt_value],
|
127 |
-
outputs = [prompt_value],
|
128 |
-
show_progress = "hidden"
|
129 |
-
)
|
130 |
run_button.click(
|
131 |
fn = infer,
|
132 |
inputs = [prompt],
|
|
|
95 |
}
|
96 |
"""
|
97 |
|
98 |
+
js="""
|
99 |
+
function createGradioPromptEvent() {
|
100 |
+
document.querySelector("#prompt").setAttribute(maxlength,"38")
|
101 |
+
}
|
102 |
+
"""
|
103 |
+
|
104 |
if torch.cuda.is_available():
|
105 |
power_device = "GPU"
|
106 |
else:
|
|
|
109 |
def limiter(txt):
|
110 |
return txt[:38]
|
111 |
|
112 |
+
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
|
|
113 |
with gr.Column(elem_id="col-container"):
|
114 |
gr.Markdown(f"""
|
115 |
# Image Generator
|
|
|
117 |
""")
|
118 |
with gr.Row():
|
119 |
prompt = gr.Textbox(
|
120 |
+
elem_id="prompt",
|
121 |
placeholder="Describe the photo",
|
122 |
container=False,
|
123 |
rtl=True,
|
|
|
126 |
with gr.Row():
|
127 |
run_button = gr.Button("Run")
|
128 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
run_button.click(
|
130 |
fn = infer,
|
131 |
inputs = [prompt],
|