Ashrafb commited on
Commit
447f123
1 Parent(s): bd2f29d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +26 -22
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
- options = [
104
- "photo anime, masterpiece, high quality, absurdres, "
105
- # Add other prompt options here...
106
- ]
107
-
108
- if prompt_text:
109
- # Generate timestamp for different prompts
110
- timestamp = str(time.time()).replace(".", "")
111
- chosen_option = random.choice(options)
112
- # Combine prompt text with chosen option and timestamp
113
- prompt_with_option_and_timestamp = f"{prompt_text}, {chosen_option} - {timestamp}"
114
- # Use prompt text with option and timestamp for generating prompts
115
- return text_gen(prompt_with_option_and_timestamp.replace(timestamp, ""))
116
- else:
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