Spaces:
Build error
Build error
PatrickSchrML
commited on
Commit
·
36dbbea
1
Parent(s):
ff9b432
added hyperparameters
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ import re
|
|
| 10 |
import os
|
| 11 |
import requests
|
| 12 |
import json
|
|
|
|
| 13 |
|
| 14 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 15 |
|
|
@@ -17,7 +18,7 @@ from share_btn import community_icon_html, loading_icon_html, share_js
|
|
| 17 |
is_gpu_busy = False
|
| 18 |
|
| 19 |
|
| 20 |
-
def infer(prompt):
|
| 21 |
global is_gpu_busy
|
| 22 |
# generator = torch.Generator(device=device).manual_seed(seed)
|
| 23 |
# print("Is GPU busy? ", is_gpu_busy)
|
|
@@ -39,7 +40,7 @@ def infer(prompt):
|
|
| 39 |
# images.append(image)
|
| 40 |
# else:
|
| 41 |
url = os.getenv('BACKEND_URL')
|
| 42 |
-
response = requests.get(url
|
| 43 |
data = json.load(BytesIO(response.content))
|
| 44 |
for image in data['output']['choices']:
|
| 45 |
image_b64 = (f"data:image/jpeg;base64,{image['image_base64']}")
|
|
@@ -102,7 +103,6 @@ css = """
|
|
| 102 |
--tw-ring-opacity: .5;
|
| 103 |
}
|
| 104 |
#advanced-btn {
|
| 105 |
-
display: none;
|
| 106 |
font-size: .7rem !important;
|
| 107 |
line-height: 19px;
|
| 108 |
margin-top: 12px;
|
|
@@ -274,7 +274,7 @@ with block:
|
|
| 274 |
randomize=True,
|
| 275 |
)
|
| 276 |
|
| 277 |
-
ex = gr.Examples(examples=examples, fn=infer, inputs=text,
|
| 278 |
outputs=[gallery, community_icon, loading_icon, share_button], cache_examples=False)
|
| 279 |
ex.dataset.headers = [""]
|
| 280 |
|
|
|
|
| 10 |
import os
|
| 11 |
import requests
|
| 12 |
import json
|
| 13 |
+
from urllib import parse
|
| 14 |
|
| 15 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 16 |
|
|
|
|
| 18 |
is_gpu_busy = False
|
| 19 |
|
| 20 |
|
| 21 |
+
def infer(prompt, n_samples, steps, scale, seed):
|
| 22 |
global is_gpu_busy
|
| 23 |
# generator = torch.Generator(device=device).manual_seed(seed)
|
| 24 |
# print("Is GPU busy? ", is_gpu_busy)
|
|
|
|
| 40 |
# images.append(image)
|
| 41 |
# else:
|
| 42 |
url = os.getenv('BACKEND_URL')
|
| 43 |
+
response = requests.get(url.format(parse.quote(prompt), n_samples, steps, scale, seed))
|
| 44 |
data = json.load(BytesIO(response.content))
|
| 45 |
for image in data['output']['choices']:
|
| 46 |
image_b64 = (f"data:image/jpeg;base64,{image['image_base64']}")
|
|
|
|
| 103 |
--tw-ring-opacity: .5;
|
| 104 |
}
|
| 105 |
#advanced-btn {
|
|
|
|
| 106 |
font-size: .7rem !important;
|
| 107 |
line-height: 19px;
|
| 108 |
margin-top: 12px;
|
|
|
|
| 274 |
randomize=True,
|
| 275 |
)
|
| 276 |
|
| 277 |
+
ex = gr.Examples(examples=examples, fn=infer, inputs=[text, samples, steps, scale, seed],
|
| 278 |
outputs=[gallery, community_icon, loading_icon, share_button], cache_examples=False)
|
| 279 |
ex.dataset.headers = [""]
|
| 280 |
|