Oranblock commited on
Commit
322f509
1 Parent(s): 3f0b9c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -73,7 +73,7 @@ CACHE_EXAMPLES = torch.cuda.is_available() and os.getenv("CACHE_EXAMPLES", "0")
73
 
74
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
75
 
76
- # Initialize the DiffusionPipeline (this was missing)
77
  pipe = DiffusionPipeline.from_pretrained(
78
  "SG161222/RealVisXL_V3.0_Turbo", # or any model of your choice
79
  torch_dtype=torch.float16,
@@ -81,11 +81,13 @@ pipe = DiffusionPipeline.from_pretrained(
81
  variant="fp16"
82
  ).to(device)
83
 
84
- # Convert mm to pixels for a specific DPI (300)
85
  def mm_to_pixels(mm, dpi=300):
86
- return int((mm / 25.4) * dpi)
 
 
87
 
88
- # Default sizes for 75mm and 35mm
89
  size_map = {
90
  "75mm": (mm_to_pixels(75), mm_to_pixels(75)), # 75mm in pixels at 300dpi
91
  "35mm": (mm_to_pixels(35), mm_to_pixels(35)), # 35mm in pixels at 300dpi
 
73
 
74
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
75
 
76
+ # Initialize the DiffusionPipeline
77
  pipe = DiffusionPipeline.from_pretrained(
78
  "SG161222/RealVisXL_V3.0_Turbo", # or any model of your choice
79
  torch_dtype=torch.float16,
 
81
  variant="fp16"
82
  ).to(device)
83
 
84
+ # Convert mm to pixels for a specific DPI (300) and ensure divisible by 8
85
  def mm_to_pixels(mm, dpi=300):
86
+ """Convert mm to pixels and make the dimensions divisible by 8."""
87
+ pixels = int((mm / 25.4) * dpi)
88
+ return pixels - (pixels % 8) # Adjust to the nearest lower multiple of 8
89
 
90
+ # Default sizes for 75mm and 35mm, rounded to nearest multiple of 8
91
  size_map = {
92
  "75mm": (mm_to_pixels(75), mm_to_pixels(75)), # 75mm in pixels at 300dpi
93
  "35mm": (mm_to_pixels(35), mm_to_pixels(35)), # 35mm in pixels at 300dpi