Update main.py
Browse files
main.py
CHANGED
@@ -54,7 +54,16 @@ import uuid # Import the UUID library
|
|
54 |
|
55 |
request_counter = 0 # Global counter to track requests
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
def generate_image(inputs, is_negative, steps, cfg_scale, seed):
|
60 |
try:
|
@@ -91,30 +100,25 @@ def generate_image(inputs, is_negative, steps, cfg_scale, seed):
|
|
91 |
|
92 |
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
import time
|
97 |
-
|
98 |
def get_prompts(prompt_text):
|
99 |
if not prompt_text:
|
100 |
-
return "Please enter text before generating prompts
|
101 |
-
raise gr.Error("Please enter text before generating prompts
|
102 |
else:
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
return text_gen("")
|
118 |
|
119 |
def initialize_api_connection():
|
120 |
global headers
|
|
|
54 |
|
55 |
request_counter = 0 # Global counter to track requests
|
56 |
|
57 |
+
def send_it1(inputs, noise_level, proc=proc1):
|
58 |
+
global request_counter
|
59 |
+
request_counter += 1
|
60 |
+
timestamp = f"{time.time()}_{request_counter}"
|
61 |
+
prompt_with_noise = add_random_noise(inputs, noise_level) + f" - {timestamp}"
|
62 |
+
while queue.qsize() >= queue_threshold:
|
63 |
+
time.sleep(2)
|
64 |
+
queue.put(prompt_with_noise)
|
65 |
+
output = proc(prompt_with_noise)
|
66 |
+
return output
|
67 |
|
68 |
def generate_image(inputs, is_negative, steps, cfg_scale, seed):
|
69 |
try:
|
|
|
100 |
|
101 |
|
102 |
|
|
|
|
|
|
|
|
|
103 |
def get_prompts(prompt_text):
|
104 |
if not prompt_text:
|
105 |
+
return "Please enter text before generating prompts."
|
106 |
+
raise gr.Error("Please enter text before generating prompts.")
|
107 |
else:
|
108 |
+
global request_counter
|
109 |
+
request_counter += 1
|
110 |
+
timestamp = f"{time.time()}_{request_counter}"
|
111 |
+
|
112 |
+
options = [
|
113 |
+
"photo anime, masterpiece, high quality, absurdres, "
|
114 |
+
# Add other prompt options here...
|
115 |
+
]
|
116 |
+
|
117 |
+
if prompt_text:
|
118 |
+
chosen_option = random.choice(options)
|
119 |
+
return text_gen(f"{prompt_text}, {chosen_option} - {timestamp}")
|
120 |
+
else:
|
121 |
+
return text_gen("", timestamp)
|
|
|
122 |
|
123 |
def initialize_api_connection():
|
124 |
global headers
|