KevinNg99 commited on
Commit
81d86e3
·
1 Parent(s): ccba969
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -50,12 +50,14 @@ except ImportError as e:
50
 
51
 
52
  BASE_DIR = os.environ.get('HUNYUANIMAGE_V2_1_MODEL_ROOT', './ckpts')
 
53
  class CheckpointDownloader:
54
  """Handles downloading of all required checkpoints for HunyuanImage."""
55
 
56
  def __init__(self, base_dir: str = BASE_DIR):
57
  self.base_dir = Path(base_dir)
58
  self.base_dir.mkdir(exist_ok=True)
 
59
 
60
  # Define all required checkpoints
61
  self.checkpoints = {
@@ -215,6 +217,7 @@ class HunyuanImageApp:
215
  ) -> Tuple[Optional[Image.Image], str]:
216
  """Generate an image using the HunyuanImage pipeline."""
217
  try:
 
218
 
219
  if self.pipeline is None:
220
  return None, "Pipeline not loaded. Please try again."
@@ -252,6 +255,8 @@ class HunyuanImageApp:
252
  ) -> Tuple[str, str]:
253
  """Enhance a prompt using the reprompt model."""
254
  try:
 
 
255
  # Load pipeline if needed
256
  if self.pipeline is None:
257
  return prompt, "Pipeline not loaded. Please try again."
@@ -284,7 +289,9 @@ class HunyuanImageApp:
284
  try:
285
  if image is None:
286
  return None, "Please upload an image to refine."
287
-
 
 
288
  # Resize image to target dimensions if needed
289
  if image.size != (width, height):
290
  image = image.resize((width, height), Image.Resampling.LANCZOS)
@@ -631,7 +638,7 @@ if __name__ == "__main__":
631
 
632
  demo.launch(
633
  server_name=args.host,
634
- server_port=args.port,
635
  share=False,
636
  show_error=True,
637
  quiet=False,
 
50
 
51
 
52
  BASE_DIR = os.environ.get('HUNYUANIMAGE_V2_1_MODEL_ROOT', './ckpts')
53
+
54
  class CheckpointDownloader:
55
  """Handles downloading of all required checkpoints for HunyuanImage."""
56
 
57
  def __init__(self, base_dir: str = BASE_DIR):
58
  self.base_dir = Path(base_dir)
59
  self.base_dir.mkdir(exist_ok=True)
60
+ print(f'Downloading checkpoints to: {self.base_dir}')
61
 
62
  # Define all required checkpoints
63
  self.checkpoints = {
 
217
  ) -> Tuple[Optional[Image.Image], str]:
218
  """Generate an image using the HunyuanImage pipeline."""
219
  try:
220
+ torch.cuda.empty_cache()
221
 
222
  if self.pipeline is None:
223
  return None, "Pipeline not loaded. Please try again."
 
255
  ) -> Tuple[str, str]:
256
  """Enhance a prompt using the reprompt model."""
257
  try:
258
+ torch.cuda.empty_cache()
259
+
260
  # Load pipeline if needed
261
  if self.pipeline is None:
262
  return prompt, "Pipeline not loaded. Please try again."
 
289
  try:
290
  if image is None:
291
  return None, "Please upload an image to refine."
292
+
293
+ torch.cuda.empty_cache()
294
+
295
  # Resize image to target dimensions if needed
296
  if image.size != (width, height):
297
  image = image.resize((width, height), Image.Resampling.LANCZOS)
 
638
 
639
  demo.launch(
640
  server_name=args.host,
641
+ # server_port=args.port,
642
  share=False,
643
  show_error=True,
644
  quiet=False,