Dagfinn1962 commited on
Commit
d4d7506
β€’
1 Parent(s): 07826b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -1,31 +1,34 @@
1
  from diffusers import StableDiffusionXLPipeline
2
  import torch
3
- from gradio import Interface, Image, Dropdown, Slider
4
  import gradio as gr
5
- import spaces
6
 
 
7
  model_id = "RunDiffusion/Juggernaut-X-v10"
8
- pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
9
- pipe = pipe.to("cuda")
10
 
11
- @spaces.GPU()
12
- def text_to_image(prompt, negative_prompt, steps, guidance_scale, progress=gr.Progress(track_tqdm=True)):
 
13
  image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=guidance_scale).images[0]
14
  return image
15
- #duplicate_button = gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
16
 
17
- gradio_interface = Interface(
18
  fn=text_to_image,
19
- allow_duplication=False,
20
  inputs=[
21
- gr.Textbox(label="Prompt", lines=4, placeholder="Enter your prompt here..."),
22
- gr.Textbox(label="Negative Prompt", lines=4, placeholder="worst quality, low quality, bad anatomy, bad hands, missing fingers, fewer digits, source_furry, source_pony, source_cartoon,3d, blurry,", ),
23
  gr.Slider(minimum=1, maximum=65, value=50, label="Steps", step=1),
24
- gr.Slider(minimum=1, maximum=20, value=7.5, label="Guidance Scale", step=0.1)
 
 
 
 
 
25
  ],
26
- outputs=Image(type="pil", show_download_button=True),
27
- examples= [" hyper realistic , detailed , real person , very pretty naked Japanese 18 yo girl, looking at the viewer, ashamed, (smile:0.7), textured fair skin, tight skirt, She is standing up in an open-air bath in a Japanese hot spring, medium breasts , skinny but fit , 8k , Leica quality , masterpiece , "],
28
  cache_examples=False,
29
  theme=gr.themes.Soft()
30
  )
31
- gradio_interface.launch()
 
 
 
1
  from diffusers import StableDiffusionXLPipeline
2
  import torch
 
3
  import gradio as gr
 
4
 
5
+ # Load the model with forced download
6
  model_id = "RunDiffusion/Juggernaut-X-v10"
7
+ pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float32, force_download=True)
8
+ pipe = pipe.to("cpu")
9
 
10
+ def text_to_image(prompt, negative_prompt, steps, guidance_scale, add_4k_masterpiece):
11
+ if add_4k_masterpiece:
12
+ prompt += ", 4k, (masterpiece)"
13
  image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=guidance_scale).images[0]
14
  return image
 
15
 
16
+ gradio_interface = gr.Interface(
17
  fn=text_to_image,
 
18
  inputs=[
19
+ gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here..."),
20
+ gr.Textbox(label="Negative Prompt", lines=2, placeholder="What to exclude from the image..."),
21
  gr.Slider(minimum=1, maximum=65, value=50, label="Steps", step=1),
22
+ gr.Slider(minimum=1, maximum=20, value=7.5, label="Guidance Scale", step=0.1),
23
+ gr.Checkbox(label="Add recommended prompt items (4k, masterpiece)", value=False)
24
+ ],
25
+ outputs=gr.Image(type="pil", show_download_button=True),
26
+ examples=[
27
+ [" hyper realistic , detailed , real person , very pretty naked Japanese 18 yo girl, looking at the viewer, ashamed, (smile:0.7), textured fair skin, tight skirt, She is standing up in an open-air bath in a Japanese hot spring, medium breasts , skinny but fit , 8k , Leica quality , masterpiece , , 4k, high quality, (masterpiece)", "worst quality, low quality, bad anatomy, bad hands, missing fingers, fewer digits, source_furry, source_pony, source_cartoon,3d, blurry,", 60, 9.5, False],
28
  ],
 
 
29
  cache_examples=False,
30
  theme=gr.themes.Soft()
31
  )
32
+
33
+ # Launch the Gradio app with share=True
34
+ gradio_interface.launch(share=True)