Spaces:
Runtime error
Runtime error
import gradio as gr | |
import requests | |
import json | |
url = "https://api.prodia.com/v1/job" | |
headers = { | |
"accept": "application/json", | |
"content-type": "application/json", | |
"X-Prodia-Key": "69e66898-010d-4cd1-9e22-090f73ad007b" | |
} | |
models = [ | |
{"name": "Timeless", "url": "timeless-1.0.ckpt 1.0.ckpt [7c4971d4]"}, | |
{"name": "Dreamlike-diffusion-2.0.", "url": "dreamlike-diffusion-2.0.safetensors [fdcf65e7]"}, | |
{"name": "Deliberate_v2", "url": "deliberate_v2.safetensors [10ec4b29]"}, | |
{"name": "Anything-v4.5-pruned", "url": "anything-v4.5-pruned.ckpt [65745d25]"}, | |
] | |
current_model = models[0] | |
models2 = [] | |
for model in models: | |
model_url = f"models/{model['url']}" | |
loaded_model = gr.Interface.load(model_url, live=True, preprocess=True) | |
models2.append(loaded_model) | |
def text_it(inputs, text_gen=text_gen): | |
return text_gen(inputs) | |
def set_model(current_model_index): | |
global current_model | |
current_model = models[current_model_index] | |
return gr.update(value=f"{current_model['name']}") | |
def send_it(inputs, model_choice): | |
proc = models2[model_choice] | |
return proc(inputs) | |
with gr.Blocks() as myface: | |
gr.HTML( | |
) | |
with gr.Row(): | |
with gr.Row(): | |
input_text = gr.Textbox(label="Iput Prompt", placeholder="", lines=1) | |
# Model selection dropdown | |
model_name1 = gr.Dropdown( | |
label="Choose Model", | |
choices=[m["name"] for m in models], | |
type="index", | |
value=current_model["name"], | |
interactive=True, | |
) | |
with gr.Row(): | |
see_prompts = gr.Button("Generate Prompts") | |
run = gr.Button("Generate Images", variant="primary") | |
if __name__ == "__main__": | |
demo.launch() | |