Updated
Browse files- kalam_data.py +4 -12
kalam_data.py
CHANGED
@@ -24,23 +24,16 @@ import gradio as ui; import requests, logging, os, json; from io import BytesIO
|
|
24 |
from PIL import Image, ImageEnhance; from requests.exceptions import *; import concurrent.futures
|
25 |
logging.basicConfig(level=logging.DEBUG)
|
26 |
|
27 |
-
def expand(expand):
|
28 |
-
pfix = '(The prompt must intricately describe every part of the image in concrete, objective detail. THINK about what the end goal of the description is, and extrapolate that to what would make satisfying images.)'
|
29 |
-
head = {'Content-Type': 'application/json'}
|
30 |
-
body = json.dumps({"topic": f"{expand} {pfix}", "word_count": 30, "writing_mode": "Simple", "story_genre": "Descriptive"})
|
31 |
-
try: return requests.post(url=os.getenv('gpt4'), headers=head, data=body, timeout=15).json()['story']
|
32 |
-
except Exception as e: print(f"Expansion error: {e}"); return expand
|
33 |
-
|
34 |
def theme_change(a, i: ui.SelectData):
|
35 |
print(f"Theme changed -> {a}")
|
36 |
return ui.Dropdown(value=theme[a]['surah'])
|
37 |
|
38 |
-
def stella(
|
39 |
data = {
|
40 |
'model_version': (None, '1'),
|
41 |
-
'prompt': (None,
|
42 |
'style_id': (None, '128'),
|
43 |
-
'negative_prompt': (None, 'hands,
|
44 |
'aspect_ratio': (None, '1:1'),
|
45 |
'high_res_results': (None, '1'),
|
46 |
'cfg': (None, '9.5'),
|
@@ -75,12 +68,11 @@ def stella(expanded, surah, mode):
|
|
75 |
def queue(a, b):
|
76 |
quantities = 4
|
77 |
result_list = [None] * quantities
|
78 |
-
gpt = expand(theme[a]['prompt'])
|
79 |
|
80 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
81 |
futures = []
|
82 |
for i in range(quantities):
|
83 |
-
future = executor.submit(lambda x: stella(
|
84 |
futures.append(future)
|
85 |
|
86 |
for i, future in enumerate(futures):
|
|
|
24 |
from PIL import Image, ImageEnhance; from requests.exceptions import *; import concurrent.futures
|
25 |
logging.basicConfig(level=logging.DEBUG)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
def theme_change(a, i: ui.SelectData):
|
28 |
print(f"Theme changed -> {a}")
|
29 |
return ui.Dropdown(value=theme[a]['surah'])
|
30 |
|
31 |
+
def stella(surah, mode):
|
32 |
data = {
|
33 |
'model_version': (None, '1'),
|
34 |
+
'prompt': (None, theme[surah]['prompt']),
|
35 |
'style_id': (None, '128'),
|
36 |
+
'negative_prompt': (None, 'hands, face, eyes, legs'),
|
37 |
'aspect_ratio': (None, '1:1'),
|
38 |
'high_res_results': (None, '1'),
|
39 |
'cfg': (None, '9.5'),
|
|
|
68 |
def queue(a, b):
|
69 |
quantities = 4
|
70 |
result_list = [None] * quantities
|
|
|
71 |
|
72 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
73 |
futures = []
|
74 |
for i in range(quantities):
|
75 |
+
future = executor.submit(lambda x: stella(a, b), i)
|
76 |
futures.append(future)
|
77 |
|
78 |
for i, future in enumerate(futures):
|