Flulike99 commited on
Commit
1bef290
·
1 Parent(s): 94e705f
Files changed (1) hide show
  1. app.py +9 -18
app.py CHANGED
@@ -18,11 +18,9 @@ secret_model = os.environ.get("MODEL_PATH")
18
  BASE_MODEL = os.environ.get("BASE_MODEL_ID")
19
 
20
  try:
21
- from diffusers import FluxTransformer2DModel
22
- from diffusers.pipelines import FluxPipeline
23
- from flux.condition import Condition
24
- from flux.generate import generate
25
- from flux.lora_controller import set_lora_scale
26
  FLUX_AVAILABLE = True
27
  except ImportError as e:
28
  print(f"Warning: FLUX components not available: {e}")
@@ -44,10 +42,6 @@ temp_dir = os.path.join(os.path.expanduser("~"), "gradio_temp")
44
  os.makedirs(temp_dir, exist_ok=True)
45
  os.environ["GRADIO_TEMP_DIR"] = temp_dir
46
 
47
- # Global state
48
- pipe: Union[FluxPipeline, None] = None
49
- use_int8 = False
50
-
51
  ADAPTER_NAME = "subject"
52
  MODEL_PATH = model_path
53
 
@@ -55,9 +49,6 @@ def get_gpu_memory_gb() -> float:
55
  return torch.cuda.get_device_properties(0).total_memory / 1024**3
56
 
57
  def init_pipeline_if_needed():
58
- global pipe
59
- if pipe is not None:
60
- return
61
 
62
  print("🚀 Initializing pipeline...")
63
 
@@ -246,7 +237,7 @@ def _place_subject_on_canvas_rect(
246
  canvas.alpha_composite(rotated, dest=(paste_x, paste_y))
247
  return canvas
248
 
249
- def apply_style(image: Image.Image, style: str, width: int = 800, height: int = 800) -> Image.Image:
250
  """Apply specified style to image with custom dimensions"""
251
  if image is None:
252
  # Create default transparent image
@@ -319,23 +310,23 @@ def create_simple_app():
319
  example_prompts = [
320
  {
321
  "title": "Handcrafted Leather Wallet",
322
- "prompt": "A hand-stitched, dark brown leather wallet lies half-open on a wooden desk with a map, next to a brass pen and compass. A stack of classic books is in the background. A warm desk lamp from the right highlights the leather texture. Classic, rustic style."
323
  },
324
  {
325
  "title": "Sparkling Water with Fresh Lemons",
326
- "prompt": "A dewy glass bottle of sparkling water on a white marble countertop, next to a sliced lemon and ice cubes. The background is a soft-focus, pale blue gradient. Lighting is bright, even, and cool-toned from above. Clean, crisp, minimalist style."
327
  },
328
  {
329
  "title": "High-tech Smartwatch",
330
- "prompt": "A titanium smartwatch with an illuminated screen rests on a black matte slate rock. The background is a blurred cityscape at night with neon bokeh. A sharp, direct light from the top-left highlights the watch's metallic edge. Futuristic, tech-focused style."
331
  },
332
  {
333
  "title": "Japanese Ramen Bowl",
334
- "prompt": "A ceramic bowl of tonkotsu ramen with chashu pork and a soft-boiled egg on a wooden table, with chopsticks beside it. Rising steam is caught in soft overhead light. The background is a blurred, cozy izakaya. Warm, authentic, and appetizing style."
335
  },
336
  {
337
  "title": "Japanese Peach Iced Tea",
338
- "prompt": "A bottle of Japanese peach iced tea beside a tall glass with tea and sparkling ice cubes. The background is a soft, warm peach and beige gradient. Lit with bright, soft light to appear crisp and refreshing. The style is clean, minimalist, and refined."
339
  }
340
  ]
341
 
 
18
  BASE_MODEL = os.environ.get("BASE_MODEL_ID")
19
 
20
  try:
21
+ from cascade.condition import Condition
22
+ from cascade.generate import generate
23
+ from cascade.lora_controller import set_lora_scale
 
 
24
  FLUX_AVAILABLE = True
25
  except ImportError as e:
26
  print(f"Warning: FLUX components not available: {e}")
 
42
  os.makedirs(temp_dir, exist_ok=True)
43
  os.environ["GRADIO_TEMP_DIR"] = temp_dir
44
 
 
 
 
 
45
  ADAPTER_NAME = "subject"
46
  MODEL_PATH = model_path
47
 
 
49
  return torch.cuda.get_device_properties(0).total_memory / 1024**3
50
 
51
  def init_pipeline_if_needed():
 
 
 
52
 
53
  print("🚀 Initializing pipeline...")
54
 
 
237
  canvas.alpha_composite(rotated, dest=(paste_x, paste_y))
238
  return canvas
239
 
240
+ def apply_style(image: Image.Image, style: str, width: int = 1024, height: int = 1024) -> Image.Image:
241
  """Apply specified style to image with custom dimensions"""
242
  if image is None:
243
  # Create default transparent image
 
310
  example_prompts = [
311
  {
312
  "title": "Handcrafted Leather Wallet",
313
+ "prompt": "A premium lifestyle advertisement for a hand-stitched dark brown leather wallet. The wallet is half-open on a timeworn walnut desk, revealing the suede interior and a few vintage travel tickets. Surround it with a rolled map, brass fountain pen, and antique compass to emphasize heritage craftsmanship. Soft amber light from a desk lamp on the right grazes the grainy leather and creates gentle shadow falloff, while a blurred wall of old books fills the background. Overall tone is classic, rustic, and aspirational."
314
  },
315
  {
316
  "title": "Sparkling Water with Fresh Lemons",
317
+ "prompt": "A product hero shot for a premium sparkling water infused with fresh lemons. Place a dewy glass bottle at the center of a white marble countertop, with a tall tumbler filled with effervescent water, thin lemon wheels, and crystal-clear ice cubes beside it. Scatter a few lemon zest curls and condensation droplets for sensory detail. Use a soft-focus pale blue and white gradient background to communicate freshness, and bathe the scene in bright, cool, top-down lighting that creates sharp reflections. Keep the styling ultra-clean, crisp, and minimalist."
318
  },
319
  {
320
  "title": "High-tech Smartwatch",
321
+ "prompt": "A cinematic tech advertisement for a titanium smartwatch with an always-on illuminated screen displaying futuristic UI graphics. Position the watch on a jagged slab of matte black slate to contrast its polished chamfered edges. Behind it, place a blurred nighttime cityscape with teal and magenta neon bokeh to suggest urban energy. Hit the product with a sharp, directional spotlight from the top left to carve out highlights along the bezel and bracelet, while subtle rim lighting separates it from the background. Mood is sleek, futuristic, and performance-driven."
322
  },
323
  {
324
  "title": "Japanese Ramen Bowl",
325
+ "prompt": "A mouthwatering food advertisement for a ceramic bowl of tonkotsu ramen. Present silky broth with two slices of torched chashu pork, a jammy soft-boiled egg, nori sheets, scallions, and sesame seeds arranged artfully. Place the bowl on a rustic wooden table with lacquered chopsticks resting on a ceramic holder, plus a tiny dish of pickled ginger for color. Capture wisps of steam drifting upward in soft overhead light, while the background falls into a blurred, amber-toned izakaya interior with paper lanterns. Atmosphere is warm, authentic, and comforting."
326
  },
327
  {
328
  "title": "Japanese Peach Iced Tea",
329
+ "prompt": "A commercial advertisement for a Japanese peach-flavored iced tea. The composition features the product bottle placed next to a tall, elegant glass filled with the tea and sparkling ice cubes. The background is a soft, warm gradient of peach and beige, creating a gentle and sophisticated atmosphere. The overall style is clean, minimalist, and refined, with bright, soft lighting that highlights the crisp, refreshing quality of the beverage."
330
  }
331
  ]
332