img_All_models / app.py
noes14155's picture
Update app.py
5f36e2a
raw
history blame
1.94 kB
import gradio as gr
import os
import sys
from pathlib import Path
models = [
{"name": "Deliberate", "url": "Masagin/Deliberate"},
{"name": "Dreamlike Anime", "url": "dreamlike-art/dreamlike-anime-1.0"},
{"name": "Dreamlike Diffusion", "url": "dreamlike-art/dreamlike-diffusion-1.0"},
{"name": "Dreamlike Photoreal", "url": "dreamlike-art/dreamlike-photoreal-2.0"},
]
current_model = models[0]
#text_gen = gr.Interface.load("spaces/daspartho/prompt-extend")
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 send_it(inputs, model_choice):
proc = models2[model_choice]
return proc(inputs)
def set_model(current_model_index):
global current_model
current_model = models[current_model_index]
return f"{current_model['name']}"
def dropdown_change():
send_it(input_text.value, model_name1.value)
with gr.Blocks() as myface:
gr.HTML(
)
with gr.Row():
with gr.Row():
input_text = gr.Textbox(label="Prompt idea", 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,
update=dropdown_change
)
run = gr.Button("Generate Images", variant="primary")
with gr.Row():
output1 = gr.Image(label="")
model_name1.change(set_model, inputs=model_name1, outputs=[output1])
run.click(send_it, inputs=[input_text, model_name1], outputs=[output1])
myface.queue(concurrency_count=200)
myface.launch(inline=True, show_api=True, max_threads=500)