Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,7 @@ def translate(text,lang):
|
|
| 61 |
if trgt.lower() == lang.lower():
|
| 62 |
translated = rslt
|
| 63 |
except:
|
| 64 |
-
|
| 65 |
|
| 66 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
| 67 |
print(ret)
|
|
@@ -77,14 +77,14 @@ def Piper(_do):
|
|
| 77 |
_do,
|
| 78 |
height=448,
|
| 79 |
width=448,
|
| 80 |
-
negative_prompt=
|
| 81 |
num_inference_steps=400,
|
| 82 |
guidance_scale=10
|
| 83 |
)
|
| 84 |
|
| 85 |
def infer(prompt):
|
| 86 |
name = generate_random_string(12)+".png"
|
| 87 |
-
_do = f'{ translate(prompt,"english") }
|
| 88 |
image = Piper(_do).images[0].save(name)
|
| 89 |
return name
|
| 90 |
|
|
@@ -103,6 +103,11 @@ css="""
|
|
| 103 |
|
| 104 |
js="""
|
| 105 |
function custom(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
window.Wait = function (Test, Success, Fail = function () { }, timeout = Number.MAX_SAFE_INTEGER) {
|
| 107 |
let seconds = 0;
|
| 108 |
function Internal() {
|
|
@@ -152,6 +157,11 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
|
| 152 |
with gr.Row():
|
| 153 |
run_button = gr.Button("Run")
|
| 154 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
run_button.click(
|
| 156 |
fn = infer,
|
| 157 |
inputs = [prompt],
|
|
|
|
| 61 |
if trgt.lower() == lang.lower():
|
| 62 |
translated = rslt
|
| 63 |
except:
|
| 64 |
+
raise Exception("Translation Error!")
|
| 65 |
|
| 66 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
| 67 |
print(ret)
|
|
|
|
| 77 |
_do,
|
| 78 |
height=448,
|
| 79 |
width=448,
|
| 80 |
+
negative_prompt='Use: vivid colors, text, logo.',
|
| 81 |
num_inference_steps=400,
|
| 82 |
guidance_scale=10
|
| 83 |
)
|
| 84 |
|
| 85 |
def infer(prompt):
|
| 86 |
name = generate_random_string(12)+".png"
|
| 87 |
+
_do = f'Use: a lot of realism, some pastel colors, { translate(prompt,"english") }, some realistic patterns.'.upper()
|
| 88 |
image = Piper(_do).images[0].save(name)
|
| 89 |
return name
|
| 90 |
|
|
|
|
| 103 |
|
| 104 |
js="""
|
| 105 |
function custom(){
|
| 106 |
+
document.querySelector("div#prompt input").setAttribute("maxlength","38");
|
| 107 |
+
}
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
"""
|
| 111 |
window.Wait = function (Test, Success, Fail = function () { }, timeout = Number.MAX_SAFE_INTEGER) {
|
| 112 |
let seconds = 0;
|
| 113 |
function Internal() {
|
|
|
|
| 157 |
with gr.Row():
|
| 158 |
run_button = gr.Button("Run")
|
| 159 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
| 160 |
+
prompt.submit(
|
| 161 |
+
fn = infer,
|
| 162 |
+
inputs = [prompt],
|
| 163 |
+
outputs = [result]
|
| 164 |
+
)
|
| 165 |
run_button.click(
|
| 166 |
fn = infer,
|
| 167 |
inputs = [prompt],
|