Spaces:
Runtime error
Runtime error
import gradio as gr | |
from pathlib import Path | |
def load_models_from_file(filename): | |
with open(filename, 'r') as f: | |
return [line.strip() for line in f] | |
if __name__ == "__main__": | |
models = load_models_from_file('models.txt') | |
print(models) | |
current_model = models[0] | |
text_gen1 = gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") | |
models2 = [gr.Interface.load(f"models/{model}", live=True, preprocess=False) for model in models] | |
def text_it1(inputs): | |
go_t1 = text_gen1(inputs) | |
return go_t1 | |
def set_model(current_model): | |
current_model = models[current_model] | |
return gr.update(label=(f"{current_model}")) | |
def send_it1(inputs, model_choice): | |
proc1 = models2[model_choice] | |
output1 = proc1(inputs) | |
return output1 | |
css = "" | |
with gr.Blocks(css=css) as myface: | |
with gr.Row(): | |
with gr.Tab("Tools"): | |
with gr.Tab("View"): | |
with gr.Row(): | |
gr.Pil(label="Crop") | |
gr.Pil(label="Crop") | |
with gr.Tab("Draw"): | |
with gr.Row(): | |
gr.Pil(label="Crop") | |
gr.ImagePaint(label="Draw") | |
gr.Textbox(label="", lines=8) | |
gr.Textbox(label="", lines=8) | |
with gr.Tab("Color Picker"): | |
with gr.Row(): | |
gr.ColorPicker(label="Color") | |
gr.ImagePaint(label="Draw") | |
with gr.Row(): | |
gr.Textbox(lines=4, label="Magic Textbox") | |
gr.Button("Generate Image") | |
with gr.Row(): | |
gr.Dropdown(label="Select Model", choices=[m for m in models], type="index", value=current_model) | |
with gr.Row(): | |
gr.Image(label=(f"{current_model}")) | |
with gr.Row(): | |
gr.Textbox(label="Prompt Idea", lines=2) | |
gr.Button("Use Short Prompt") | |
gr.Button("Extend Idea") | |
myface.queue(concurrency_count=200) | |
myface.launch(inline=True, show_api=False, max_threads=400) | |