Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,16 @@ 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=
|
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,
|
@@ -39,6 +43,7 @@ with gr.Blocks(css=css) as dalle:
|
|
39 |
with gr.Row():
|
40 |
with gr.Column(elem_id="prompt-container"):
|
41 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Описание изображения", lines=1, elem_id="prompt-text-input")
|
|
|
42 |
|
43 |
|
44 |
with gr.Tab("Расширенные настройки"):
|
@@ -49,6 +54,6 @@ with gr.Blocks(css=css) as dalle:
|
|
49 |
with gr.Row():
|
50 |
image_output = gr.Image(type="pil", label="Изображение", elem_id="gallery")
|
51 |
|
52 |
-
text_button.click(query, inputs=[text_prompt, negative_prompt], outputs=image_output)
|
53 |
|
54 |
dalle.launch(show_api=False)
|
|
|
11 |
API_TOKEN = os.getenv("HF_READ_TOKEN") # it is free
|
12 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
13 |
|
14 |
+
def query(prompt, model, is_negative=False, steps=20, cfg_scale=7, seed=None):
|
15 |
language = detect(prompt)
|
16 |
|
17 |
if language == 'ru':
|
18 |
prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
|
19 |
print(prompt)
|
20 |
+
|
21 |
+
if model == 'DALL-E 3 XL'
|
22 |
+
API_URL = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
|
23 |
+
|
24 |
payload = {
|
25 |
"inputs": prompt,
|
26 |
"is_negative": is_negative,
|
|
|
43 |
with gr.Row():
|
44 |
with gr.Column(elem_id="prompt-container"):
|
45 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Описание изображения", lines=1, elem_id="prompt-text-input")
|
46 |
+
model = gr.Radio(label="Модель", value="DALL-E 3 XL", choices=["DALL-E 3 XL"])
|
47 |
|
48 |
|
49 |
with gr.Tab("Расширенные настройки"):
|
|
|
54 |
with gr.Row():
|
55 |
image_output = gr.Image(type="pil", label="Изображение", elem_id="gallery")
|
56 |
|
57 |
+
text_button.click(query, inputs=[text_prompt, model, negative_prompt], outputs=image_output)
|
58 |
|
59 |
dalle.launch(show_api=False)
|