Update main.py
Browse files
main.py
CHANGED
|
@@ -13,6 +13,7 @@ import requests
|
|
| 13 |
import io
|
| 14 |
from PIL import Image
|
| 15 |
import base64
|
|
|
|
| 16 |
|
| 17 |
app = FastAPI()
|
| 18 |
|
|
@@ -69,7 +70,12 @@ def generate_image(inputs, is_negative, steps, cfg_scale, seed):
|
|
| 69 |
global request_counter
|
| 70 |
request_counter += 1
|
| 71 |
timestamp = f"{time.time()}_{request_counter}"
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
payload = {
|
| 74 |
"inputs": prompt_with_noise,
|
| 75 |
"is_negative": is_negative,
|
|
@@ -93,6 +99,7 @@ def generate_image(inputs, is_negative, steps, cfg_scale, seed):
|
|
| 93 |
|
| 94 |
|
| 95 |
|
|
|
|
| 96 |
def get_prompts(prompt_text):
|
| 97 |
if not prompt_text:
|
| 98 |
return "Please enter text before generating prompts.رجاء ادخل النص اولا"
|
|
|
|
| 13 |
import io
|
| 14 |
from PIL import Image
|
| 15 |
import base64
|
| 16 |
+
from deep_translator import GoogleTranslator
|
| 17 |
|
| 18 |
app = FastAPI()
|
| 19 |
|
|
|
|
| 70 |
global request_counter
|
| 71 |
request_counter += 1
|
| 72 |
timestamp = f"{time.time()}_{request_counter}"
|
| 73 |
+
|
| 74 |
+
# Translate inputs to English
|
| 75 |
+
translator_to_en = GoogleTranslator(source='auto', target='english')
|
| 76 |
+
english_inputs = translator_to_en.translate(inputs)
|
| 77 |
+
|
| 78 |
+
prompt_with_noise = add_random_noise(english_inputs) + f" - {timestamp}"
|
| 79 |
payload = {
|
| 80 |
"inputs": prompt_with_noise,
|
| 81 |
"is_negative": is_negative,
|
|
|
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
+
|
| 103 |
def get_prompts(prompt_text):
|
| 104 |
if not prompt_text:
|
| 105 |
return "Please enter text before generating prompts.رجاء ادخل النص اولا"
|