Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -89,7 +89,7 @@ def mistral_nemo_call(prompt, API_TOKEN, model="mistralai/Mistral-Nemo-Instruct-
|
|
89 |
response += message.choices[0].delta.content
|
90 |
return response
|
91 |
|
92 |
-
def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, huggingface_api_key=None, use_dev=False, enhance_prompt_option=False, use_mistral_nemo=False):
|
93 |
# Determine which API URL to use
|
94 |
api_url = API_URL_DEV if use_dev else API_URL
|
95 |
|
@@ -117,10 +117,10 @@ def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Ka
|
|
117 |
|
118 |
original_prompt = prompt
|
119 |
if enhance_prompt_option:
|
120 |
-
prompt = enhance_prompt_v2(prompt, style=
|
121 |
print(f'\033[1mGeneration {key} enhanced prompt:\033[0m {prompt}')
|
122 |
if use_mistral_nemo:
|
123 |
-
prompt = mistral_nemo_call(prompt,API_TOKEN=API_TOKEN,style=
|
124 |
print(f'\033[1mGeneration {key} Mistral-Nemo prompt:\033[0m {prompt}')
|
125 |
|
126 |
final_prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
@@ -247,8 +247,11 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
247 |
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
|
248 |
huggingface_api_key = gr.Textbox(label="Hugging Face API Key (required for API calls)", placeholder="Enter your Hugging Face API Key here", type="password", elem_id="api-key")
|
249 |
use_dev = gr.Checkbox(label="Use Dev API", value=False, elem_id="use-dev-checkbox")
|
|
|
250 |
enhance_prompt_option = gr.Checkbox(label="Enhance Prompt", value=False, elem_id="enhance-prompt-checkbox")
|
251 |
use_mistral_nemo = gr.Checkbox(label="Use Mistral Nemo", value=False, elem_id="use-mistral-checkbox")
|
|
|
|
|
252 |
with gr.Row():
|
253 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
254 |
with gr.Row():
|
@@ -258,6 +261,6 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
258 |
final_prompt_output = gr.Textbox(label="Final Prompt", elem_id="final-prompt-output")
|
259 |
|
260 |
# Adjust the click function to include the API key, use_dev, and enhance_prompt_option as inputs
|
261 |
-
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, huggingface_api_key, use_dev, enhance_prompt_option, use_mistral_nemo], outputs=[image_output, seed_output, final_prompt_output])
|
262 |
|
263 |
app.launch(show_api=True, share=False)
|
|
|
89 |
response += message.choices[0].delta.content
|
90 |
return response
|
91 |
|
92 |
+
def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, huggingface_api_key=None, use_dev=False,enhance_prompt_style="generic", enhance_prompt_option=False, nemo_enhance_prompt_style="generic", use_mistral_nemo=False):
|
93 |
# Determine which API URL to use
|
94 |
api_url = API_URL_DEV if use_dev else API_URL
|
95 |
|
|
|
117 |
|
118 |
original_prompt = prompt
|
119 |
if enhance_prompt_option:
|
120 |
+
prompt = enhance_prompt_v2(prompt, style=enhance_prompt_style)
|
121 |
print(f'\033[1mGeneration {key} enhanced prompt:\033[0m {prompt}')
|
122 |
if use_mistral_nemo:
|
123 |
+
prompt = mistral_nemo_call(prompt, API_TOKEN=API_TOKEN, style=nemo_enhance_prompt_style)
|
124 |
print(f'\033[1mGeneration {key} Mistral-Nemo prompt:\033[0m {prompt}')
|
125 |
|
126 |
final_prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
|
|
247 |
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
|
248 |
huggingface_api_key = gr.Textbox(label="Hugging Face API Key (required for API calls)", placeholder="Enter your Hugging Face API Key here", type="password", elem_id="api-key")
|
249 |
use_dev = gr.Checkbox(label="Use Dev API", value=False, elem_id="use-dev-checkbox")
|
250 |
+
enhance_prompt_style = gr.Textbox(label="Enhance Prompt Style", placeholder="Enter style for the prompt enhancer here", elem_id="enhance-prompt-style")
|
251 |
enhance_prompt_option = gr.Checkbox(label="Enhance Prompt", value=False, elem_id="enhance-prompt-checkbox")
|
252 |
use_mistral_nemo = gr.Checkbox(label="Use Mistral Nemo", value=False, elem_id="use-mistral-checkbox")
|
253 |
+
nemo_prompt_style = gr.Textbox(label="Nemo Enhance Prompt Style", placeholder="Enter style for the prompt enhancer here", elem_id="nemo-enhance-prompt-style")
|
254 |
+
|
255 |
with gr.Row():
|
256 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
257 |
with gr.Row():
|
|
|
261 |
final_prompt_output = gr.Textbox(label="Final Prompt", elem_id="final-prompt-output")
|
262 |
|
263 |
# Adjust the click function to include the API key, use_dev, and enhance_prompt_option as inputs
|
264 |
+
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, huggingface_api_key, use_dev, enhance_prompt_style,enhance_prompt_option, enhance_prompt_style, use_mistral_nemo], outputs=[image_output, seed_output, final_prompt_output])
|
265 |
|
266 |
app.launch(show_api=True, share=False)
|