Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,16 +9,17 @@ from deep_translator import GoogleTranslator
|
|
9 |
import json
|
10 |
|
11 |
|
12 |
-
API_URL = "https://api-inference.huggingface.co/models/ovi054/rmx_flux"
|
13 |
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
14 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
15 |
timeout = 100
|
16 |
|
17 |
-
def query(prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M Karras", seed=-1, strength=0.7):
|
18 |
if prompt == "" or prompt == None:
|
19 |
return None
|
20 |
|
21 |
key = random.randint(0, 999)
|
|
|
|
|
22 |
|
23 |
API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN")])
|
24 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
@@ -53,6 +54,13 @@ def query(prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M
|
|
53 |
print(f"Error when trying to open the image: {e}")
|
54 |
return None
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
css = """
|
57 |
#app-container {
|
58 |
max-width: 600px;
|
@@ -68,6 +76,8 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
68 |
with gr.Column(elem_id="prompt-container"):
|
69 |
with gr.Row():
|
70 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
|
|
|
|
71 |
with gr.Row():
|
72 |
with gr.Accordion("Advanced Settings", open=False):
|
73 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
|
@@ -81,7 +91,15 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
81 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
82 |
with gr.Row():
|
83 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
-
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)
|
86 |
|
87 |
app.launch(show_api=False, share=False)
|
|
|
9 |
import json
|
10 |
|
11 |
|
|
|
12 |
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
13 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
14 |
timeout = 100
|
15 |
|
16 |
+
def query(lora_id="ByteDance/Hyper-SD", prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M Karras", seed=-1, strength=0.7):
|
17 |
if prompt == "" or prompt == None:
|
18 |
return None
|
19 |
|
20 |
key = random.randint(0, 999)
|
21 |
+
|
22 |
+
API_URL = "https://api-inference.huggingface.co/models/"+ lora_id
|
23 |
|
24 |
API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN")])
|
25 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
|
54 |
print(f"Error when trying to open the image: {e}")
|
55 |
return None
|
56 |
|
57 |
+
|
58 |
+
examples = [
|
59 |
+
"a tiny astronaut hatching from an egg on the moon",
|
60 |
+
"a cat holding a sign that says hello world",
|
61 |
+
"an anime illustration of a wiener schnitzel",
|
62 |
+
]
|
63 |
+
|
64 |
css = """
|
65 |
#app-container {
|
66 |
max-width: 600px;
|
|
|
76 |
with gr.Column(elem_id="prompt-container"):
|
77 |
with gr.Row():
|
78 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
79 |
+
with gr.Row():
|
80 |
+
custom_lora = gr.Textbox(label="Custom LoRA", info="LoRA Hugging Face path", placeholder="multimodalart/vintage-ads-flux")
|
81 |
with gr.Row():
|
82 |
with gr.Accordion("Advanced Settings", open=False):
|
83 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
|
|
|
91 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
92 |
with gr.Row():
|
93 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
94 |
+
|
95 |
+
gr.Examples(
|
96 |
+
examples = examples,
|
97 |
+
fn = infer,
|
98 |
+
inputs = [prompt],
|
99 |
+
outputs = [result, seed],
|
100 |
+
cache_examples="lazy"
|
101 |
+
)
|
102 |
|
103 |
+
text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)
|
104 |
|
105 |
app.launch(show_api=False, share=False)
|