Spaces:
Sleeping
Sleeping
update app.py
Browse files6 unmodified lines7891011121314151617181920211 unmodified line2324252627287 unmodified lines36373839404126 unmodified lines686970717273747576777879808156 unmodified lines1381391401411421436 unmodified linesimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to useif torch.cuda.is_available():torch_dtype = torch.float16else:torch_dtype = torch.float32pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)pipe = pipe.to(device)MAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 10241 unmodified line# @spaces.GPU #[uncomment to use ZeroGPU]def infer(prompt,negative_prompt,seed,7 unmodified linesif randomize_seed:seed = random.randint(0, MAX_SEED)generator = torch.Generator().manual_seed(seed)image = pipe(26 unmodified lineswith gr.Column(elem_id="col-container"):gr.Markdown(" # Text-to-Image Gradio Template")with gr.Row():prompt = gr.Text(label="Prompt",show_label=False,max_lines=1,placeholder="Enter your prompt",container=False,)run_button = gr.Button("Run", scale=0, variant="primary")56 unmodified linestriggers=[run_button.click, prompt.submit],fn=infer,inputs=[prompt,negative_prompt,seed,6 unmodified lines7891011121314151617181920211 unmodified line232425262728297 unmodified lines3738394041424344454626 unmodified lines73747576777879808182838485868788899091929394959697989910010110256 unmodified lines1591601611621631641656 unmodified linesimport torchdevice = "cuda" if torch.cuda.is_available() else "cpu"# model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to useif torch.cuda.is_available():torch_dtype = torch.float16else:torch_dtype = torch.float32# pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)# pipe = pipe.to(device)MAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 10241 unmodified line# @spaces.GPU #[uncomment to use ZeroGPU]def infer(model_id,prompt,negative_prompt,seed,7 unmodified linesif randomize_seed:seed = random.randint(0, MAX_SEED)print(f"Model id: {model_id}")pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch_dtype)pipe = pipe.to(device)generator = torch.Generator().manual_seed(seed)image = pipe(26 unmodified lineswith gr.Column(elem_id="col-container"):gr.Markdown(" # Text-to-Image Gradio Template")prompt = gr.Text(label="Prompt",show_label=False,max_lines=1,placeholder="Enter your prompt",container=False,)with gr.Row():model_id = gr.Text(label="Model ID",show_label=False,max_lines=1,placeholder="Enter model id",container=False,value="CompVis/stable-diffusion-v1-4",)# prompt = gr.Text(# label="Prompt",# show_label=False,# max_lines=1,# placeholder="Enter your prompt",# container=False,# )run_button = gr.Button("Run", scale=0, variant="primary")56 unmodified linestriggers=[run_button.click, prompt.submit],fn=infer,inputs=[model_id,prompt,negative_prompt,seed,
app.py+28-6