Update app.py
Browse files
app.py
CHANGED
@@ -4,12 +4,19 @@ import io
|
|
4 |
import random
|
5 |
import os
|
6 |
from PIL import Image
|
|
|
|
|
7 |
|
8 |
API_URL = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
|
9 |
API_TOKEN = os.getenv("HF_READ_TOKEN") # it is free
|
10 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
11 |
|
12 |
def query(prompt, is_negative=False, steps=1, cfg_scale=6, seed=None):
|
|
|
|
|
|
|
|
|
|
|
13 |
payload = {
|
14 |
"inputs": prompt,
|
15 |
"is_negative": is_negative,
|
|
|
4 |
import random
|
5 |
import os
|
6 |
from PIL import Image
|
7 |
+
from deep_translator import GoogleTranslator
|
8 |
+
from langdetect import detect
|
9 |
|
10 |
API_URL = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
|
11 |
API_TOKEN = os.getenv("HF_READ_TOKEN") # it is free
|
12 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
13 |
|
14 |
def query(prompt, is_negative=False, steps=1, cfg_scale=6, seed=None):
|
15 |
+
language = detect(prompt)
|
16 |
+
|
17 |
+
if language == 'ru':
|
18 |
+
prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
|
19 |
+
print(prompt)
|
20 |
payload = {
|
21 |
"inputs": prompt,
|
22 |
"is_negative": is_negative,
|