Spaces:
Sleeping
Sleeping
Update app.py
Browse files5 unmodified lines678910111213141516171819208 unmodified lines293031323334353637383940414243444544 unmodified lines9091929394959612 unmodified lines10911011111211311411545 unmodified lines1611621631641651667 unmodified lines1741751761775 unmodified linesfrom diffusers import DiffusionPipelineimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"MODEL_OPTIONS = [("stabilityai/sdxl-turbo", "SDXL Turbo (Быстро)"),("hakurei/waifu-diffusion", "Что-то альтернативное"),]DEFAULT_MODEL_ID = "stabilityai/sdxl-turbo"# model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to usePIPELINES = {}def load_pipelines():# SDXL Turbo8 unmodified linespipe = pipe.to(device)PIPELINES[mid] = pipeif torch.cuda.is_available():torch_dtype = torch.float16else:torch_dtype = torch.float32load_pipelines()MAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 1024@spaces.GPU #[uncomment to use ZeroGPU]def infer(44 unmodified lineswith gr.Blocks(css=css) as demo:with gr.Column(elem_id="col-container"):gr.Markdown(" # Text-to-Image Gradio Template")with gr.Row():prompt = gr.Text(label="Prompt",12 unmodified lineslabel="Negative prompt",max_lines=1,placeholder="Enter a negative prompt",visible=False,)seed = gr.Slider(45 unmodified linestriggers=[run_button.click, prompt.submit],fn=infer,inputs=[prompt,negative_prompt,seed,7 unmodified lines)if __name__ == "__main__":demo.launch()5 unmodified lines678910111213141516171819202122232425262728298 unmodified lines383940414243444544 unmodified lines9091929394959697989910010112 unmodified lines11411511611711811912012145 unmodified lines1671681691701711721737 unmodified lines1811821831845 unmodified linesfrom diffusers import DiffusionPipelineimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"MODEL_OPTIONS = [("stabilityai/sdxl-turbo", "SDXL Turbo (Быстро)"),("hakurei/waifu-diffusion", "Что-то альтернативное"),]DEFAULT_MODEL_ID = "stabilityai/sdxl-turbo"if torch.cuda.is_available():torch_dtype = torch.float16else:torch_dtype = torch.float32MAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 1024PIPELINES = {}def load_pipelines():# SDXL Turbo8 unmodified linespipe = pipe.to(device)PIPELINES[mid] = pipeload_pipelines()@spaces.GPU #[uncomment to use ZeroGPU]def infer(44 unmodified lineswith gr.Blocks(css=css) as demo:with gr.Column(elem_id="col-container"):gr.Markdown(" # Text-to-Image Gradio Template")model_id = gr.Dropdown(choices=[m[0] for m in MODEL_OPTIONS],label="Model",value=DEFAULT_MODEL_ID,)with gr.Row():prompt = gr.Text(label="Prompt",12 unmodified lineslabel="Negative prompt",max_lines=1,placeholder="Enter a negative prompt",visible=True,value="dog, cat")seed = gr.Slider(45 unmodified linestriggers=[run_button.click, prompt.submit],fn=infer,inputs=[model_id,prompt,negative_prompt,seed,7 unmodified lines)if __name__ == "__main__":demo.launch()
app.py+21-14