multimodalart HF Staff commited on
Commit
40b8efc
·
verified ·
1 Parent(s): 0d85dd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -22
app.py CHANGED
@@ -25,7 +25,7 @@ pipe = GlmImagePipeline.from_pretrained(
25
  def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024, height=1024,
26
  num_inference_steps=50, guidance_scale=1.5, progress=gr.Progress(track_tqdm=True)):
27
  """Main inference function"""
28
-
29
  if randomize_seed:
30
  seed = random.randint(0, MAX_SEED)
31
 
@@ -34,7 +34,8 @@ def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024,
34
  height = (height // 32) * 32
35
 
36
  generator = torch.Generator(device="cuda").manual_seed(seed)
37
-
 
38
  # Prepare image list for image-to-image mode
39
  image_list = None
40
  if input_images is not None and len(input_images) > 0:
@@ -46,7 +47,7 @@ def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024,
46
  elif isinstance(img, Image.Image):
47
  img = img.convert("RGB")
48
  image_list.append(img)
49
-
50
  pipe_kwargs = {
51
  "prompt": prompt,
52
  "height": height,
@@ -55,11 +56,11 @@ def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024,
55
  "guidance_scale": guidance_scale,
56
  "generator": generator,
57
  }
58
-
59
  # Add images for image-to-image mode
60
  if image_list is not None:
61
  pipe_kwargs["image"] = image_list
62
-
63
  image = pipe(**pipe_kwargs).images[0]
64
 
65
  return image, seed
@@ -98,23 +99,6 @@ def update_dimensions_from_image(image_list):
98
 
99
  return new_width, new_height
100
 
101
-
102
- # Text-to-Image examples
103
- examples_t2i = [
104
- ["A beautifully designed modern food magazine style dessert recipe illustration, themed around a raspberry mousse cake. Clean and bright layout with a bold black title 'Raspberry Mousse Cake Recipe Guide', soft-lit close-up of the finished cake showing light pink layers with fresh raspberries and mint leaves."],
105
- ["A kawaii die-cut sticker of a chubby orange cat, featuring big sparkly eyes and a happy smile with paws raised in greeting and a heart-shaped pink nose. Smooth rounded lines with black outlines and soft gradient shading with pink cheeks."],
106
- ["Soaking wet capybara taking shelter under a banana leaf in the rainy jungle, close up photo, water droplets visible on fur, lush green background"],
107
- ["A photorealistic portrait of an astronaut in a detailed spacesuit, floating in space with Earth visible in the background, dramatic lighting from the sun"],
108
- ["An elegant art deco poster design for a jazz concert, featuring geometric patterns in gold and deep blue, stylized saxophone silhouette, vintage typography"],
109
- ]
110
-
111
- # Image-to-Image examples
112
- examples_i2i = [
113
- ["Transform this scene into a cyberpunk cityscape at night with neon lights and flying cars"],
114
- ["Replace the background with an underwater coral reef scene with tropical fish"],
115
- ["Convert this to a watercolor painting style with soft pastel colors"],
116
- ]
117
-
118
  css = """
119
  #col-container {
120
  margin: 0 auto;
 
25
  def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024, height=1024,
26
  num_inference_steps=50, guidance_scale=1.5, progress=gr.Progress(track_tqdm=True)):
27
  """Main inference function"""
28
+ print("Randomizing seed")
29
  if randomize_seed:
30
  seed = random.randint(0, MAX_SEED)
31
 
 
34
  height = (height // 32) * 32
35
 
36
  generator = torch.Generator(device="cuda").manual_seed(seed)
37
+
38
+ print("preparing iages")
39
  # Prepare image list for image-to-image mode
40
  image_list = None
41
  if input_images is not None and len(input_images) > 0:
 
47
  elif isinstance(img, Image.Image):
48
  img = img.convert("RGB")
49
  image_list.append(img)
50
+ print("handling kwargs")
51
  pipe_kwargs = {
52
  "prompt": prompt,
53
  "height": height,
 
56
  "guidance_scale": guidance_scale,
57
  "generator": generator,
58
  }
59
+ print("adding images")
60
  # Add images for image-to-image mode
61
  if image_list is not None:
62
  pipe_kwargs["image"] = image_list
63
+ print("running kwargs")
64
  image = pipe(**pipe_kwargs).images[0]
65
 
66
  return image, seed
 
99
 
100
  return new_width, new_height
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  css = """
103
  #col-container {
104
  margin: 0 auto;