educrpg commited on
Commit
dc8f8ae
Β·
verified Β·
1 Parent(s): 6d9d748

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -10,10 +10,10 @@ from huggingface_hub import InferenceClient
10
  dtype = torch.bfloat16
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
12
 
13
- pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
14
  sdxl = InferenceClient(model="stabilityai/stable-diffusion-xl-base-1.0", token=os.environ['HF_TOKEN'])
15
 
16
- #pipeline2Image = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtypes=torch.bfloat16).to("cpu")
17
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
  MAX_IMAGE_SIZE = 2048
@@ -23,18 +23,18 @@ MAX_IMAGE_SIZE = 2048
23
  def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=5.0, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
24
  if randomize_seed:
25
  seed = random.randint(0, MAX_SEED)
26
- generator = torch.Generator().manual_seed(seed)
27
- image = pipe(
28
- prompt=prompt,
29
- width=width,
30
- height=height,
31
- num_inference_steps=num_inference_steps,
32
- generator=generator,
33
- guidance_scale=guidance_scale
34
- ).images[0]
35
  image = sdxl.text_to_image(
36
  "Dark gothic city in a misty night, lit by street lamps. A man in a cape is walking away from us",
37
- guidance_scale=9, num_inference_steps=50
38
  )
39
 
40
  return image, seed
 
10
  dtype = torch.bfloat16
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
12
 
13
+ #pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
14
  sdxl = InferenceClient(model="stabilityai/stable-diffusion-xl-base-1.0", token=os.environ['HF_TOKEN'])
15
 
16
+ pipeline2Image = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtypes=torch.bfloat16).to("cpu")
17
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
  MAX_IMAGE_SIZE = 2048
 
23
  def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=5.0, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
24
  if randomize_seed:
25
  seed = random.randint(0, MAX_SEED)
26
+ # generator = torch.Generator().manual_seed(seed)
27
+ # image = pipe(
28
+ # prompt=prompt,
29
+ # width=width,
30
+ # height=height,
31
+ # num_inference_steps=num_inference_steps,
32
+ # generator=generator,
33
+ # guidance_scale=guidance_scale
34
+ # ).images[0]
35
  image = sdxl.text_to_image(
36
  "Dark gothic city in a misty night, lit by street lamps. A man in a cape is walking away from us",
37
+ guidance_scale=9, num_inference_steps=num_inference_steps, seed=seed,width=width, height=height)
38
  )
39
 
40
  return image, seed