Spaces:
Runtime error
Runtime error
Commit
·
af1bc9d
1
Parent(s):
5d5215f
Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ def generate_txt2img(current_model, prompt, is_negative=False, image_style="None
|
|
49 |
API_URL = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
|
50 |
|
51 |
|
52 |
-
API_TOKEN = "
|
53 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
54 |
|
55 |
|
@@ -86,7 +86,6 @@ def generate_txt2img(current_model, prompt, is_negative=False, image_style="None
|
|
86 |
"seed": seed if seed is not None else random.randint(-1, 2147483647)
|
87 |
}
|
88 |
|
89 |
-
# Вставьте ваш код для запроса к модели и получения изображения
|
90 |
image_bytes = requests.post(API_URL, headers=headers, json=payload).content
|
91 |
image = Image.open(io.BytesIO(image_bytes))
|
92 |
return image
|
@@ -214,23 +213,28 @@ css = """
|
|
214 |
.tabitem{border: 0 !important}
|
215 |
"""
|
216 |
|
217 |
-
with gr.Blocks(css=css) as
|
|
|
218 |
favicon = '<img src="https://www.gstatic.com/android/keyboard/emojikitchen/20201001/u1f917/u1f917_u1f31e.png" width="48px" style="display: inline">'
|
219 |
gr.Markdown(
|
220 |
f"""<h1><center>{favicon} HuggingDiffusion</center></h1>
|
221 |
"""
|
222 |
)
|
|
|
223 |
with gr.Row(elem_id="prompt-container"):
|
224 |
current_model = gr.Dropdown(label="Current Model", choices=list_models, value=list_models[1])
|
|
|
225 |
with gr.Row(elem_id="prompt-container"):
|
226 |
text_prompt = gr.Textbox(label="Prompt", placeholder="a cute cat", lines=1, elem_id="prompt-text-input")
|
227 |
text_button = gr.Button("Generate", variant='primary', elem_id="gen-button")
|
|
|
228 |
with gr.Row():
|
229 |
image_output = gr.Image(type="pil", label="Output Image", elem_id="gallery")
|
|
|
230 |
with gr.Accordion("Advanced settings", open=False):
|
231 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="text, blurry, fuzziness", lines=1, elem_id="negative-prompt-text-input")
|
232 |
image_style = gr.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="None style", allow_custom_value=False)
|
233 |
|
234 |
text_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
|
235 |
|
236 |
-
|
|
|
49 |
API_URL = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
|
50 |
|
51 |
|
52 |
+
API_TOKEN = os.environ.get("HF_READ_TOKEN")
|
53 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
54 |
|
55 |
|
|
|
86 |
"seed": seed if seed is not None else random.randint(-1, 2147483647)
|
87 |
}
|
88 |
|
|
|
89 |
image_bytes = requests.post(API_URL, headers=headers, json=payload).content
|
90 |
image = Image.open(io.BytesIO(image_bytes))
|
91 |
return image
|
|
|
213 |
.tabitem{border: 0 !important}
|
214 |
"""
|
215 |
|
216 |
+
with gr.Blocks(css=css) as demo:
|
217 |
+
|
218 |
favicon = '<img src="https://www.gstatic.com/android/keyboard/emojikitchen/20201001/u1f917/u1f917_u1f31e.png" width="48px" style="display: inline">'
|
219 |
gr.Markdown(
|
220 |
f"""<h1><center>{favicon} HuggingDiffusion</center></h1>
|
221 |
"""
|
222 |
)
|
223 |
+
|
224 |
with gr.Row(elem_id="prompt-container"):
|
225 |
current_model = gr.Dropdown(label="Current Model", choices=list_models, value=list_models[1])
|
226 |
+
|
227 |
with gr.Row(elem_id="prompt-container"):
|
228 |
text_prompt = gr.Textbox(label="Prompt", placeholder="a cute cat", lines=1, elem_id="prompt-text-input")
|
229 |
text_button = gr.Button("Generate", variant='primary', elem_id="gen-button")
|
230 |
+
|
231 |
with gr.Row():
|
232 |
image_output = gr.Image(type="pil", label="Output Image", elem_id="gallery")
|
233 |
+
|
234 |
with gr.Accordion("Advanced settings", open=False):
|
235 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="text, blurry, fuzziness", lines=1, elem_id="negative-prompt-text-input")
|
236 |
image_style = gr.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="None style", allow_custom_value=False)
|
237 |
|
238 |
text_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
|
239 |
|
240 |
+
demo.launch(show_api=False)
|