ameerazam08 commited on
Commit
064f75e
1 Parent(s): 7d9dd48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -8,7 +8,7 @@ import random
8
  import gradio as gr
9
  import numpy as np
10
  import PIL.Image
11
- import spaces
12
  import torch
13
  from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler
14
  from huggingface_hub import hf_hub_download
@@ -28,12 +28,9 @@ USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE") == "1"
28
  ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD") == "1"
29
 
30
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
31
- if torch.cuda.is_available():
32
- #Lykon/dreamshaper-xl-1-0
33
- # pipe = AutoPipelineForText2Image.from_pretrained('stabilityai/stable-diffusion-xl-base-1.0',)# torch_dtype=torch.float16, variant="safetensors")
34
- pipe = AutoPipelineForText2Image.from_pretrained('stabilityai/stable-diffusion-xl-base-1.0',use_safetensors=True)
35
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++")
36
- pipe = pipe.to(device)
37
 
38
 
39
  pipe.load_lora_weights(
@@ -45,6 +42,7 @@ pipe.load_lora_weights(
45
  adapter_name="res_adapter",
46
  )
47
  pipe.set_adapters(["res_adapter"], adapter_weights=[1.0])
 
48
 
49
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
50
  if randomize_seed:
@@ -52,7 +50,7 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
52
  return seed
53
 
54
 
55
- @spaces.GPU(enable_queue=True)
56
  def generate(
57
  prompt: str,
58
  negative_prompt: str = "",
@@ -89,6 +87,7 @@ def generate(
89
  num_inference_steps=num_inference_steps_base,
90
  generator=generator,
91
  output_type="pil").images[0]
 
92
 
93
 
94
  res_adapt=pipe(
 
8
  import gradio as gr
9
  import numpy as np
10
  import PIL.Image
11
+ # import spaces
12
  import torch
13
  from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler
14
  from huggingface_hub import hf_hub_download
 
28
  ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD") == "1"
29
 
30
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
31
+ pipe = AutoPipelineForText2Image.from_pretrained('stabilityai/stable-diffusion-xl-base-1.0',use_safetensors=True)# torch_dtype=torch.float16, variant="safetensors")
32
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++")
33
+
 
 
 
34
 
35
 
36
  pipe.load_lora_weights(
 
42
  adapter_name="res_adapter",
43
  )
44
  pipe.set_adapters(["res_adapter"], adapter_weights=[1.0])
45
+ pipe = pipe.to(device)
46
 
47
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
48
  if randomize_seed:
 
50
  return seed
51
 
52
 
53
+ # @spaces.GPU(enable_queue=True)
54
  def generate(
55
  prompt: str,
56
  negative_prompt: str = "",
 
87
  num_inference_steps=num_inference_steps_base,
88
  generator=generator,
89
  output_type="pil").images[0]
90
+
91
 
92
 
93
  res_adapt=pipe(