shaheerawan3 commited on
Commit
5a6c7a7
·
verified ·
1 Parent(s): ff099b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -52,22 +52,27 @@ class EnhancedVideoGenerator:
52
  def initialize_models(self):
53
  """Initialize all AI models"""
54
  try:
55
- # Text generation model
56
- self.text_generator = pipeline(
57
- 'text-generation',
58
- model='gpt2',
59
- device=0 if self.device == "cuda" else -1
60
- )
61
-
62
- # Initialize free image generation model
63
- self.image_model = AutoModelForCausalLM.from_pretrained(
64
- "CompVis/stable-diffusion-v1-4",
65
- torch_dtype=torch.float16 if self.device == "cuda" else torch.float32
66
- ).to(self.device)
67
-
 
 
 
 
68
  except Exception as e:
69
  self.logger.error(f"Model initialization failed: {str(e)}")
70
- raise
 
71
 
72
  def setup_workspace(self):
73
  """Set up working directory and resources"""
 
52
  def initialize_models(self):
53
  """Initialize all AI models"""
54
  try:
55
+ # Text generation model initialization with error handling
56
+ try:
57
+ self.text_generator = pipeline(
58
+ 'text-generation',
59
+ model='gpt2',
60
+ device=0 if self.device == "cuda" else -1
61
+ )
62
+ except Exception as e:
63
+ self.logger.warning(f"Text generator initialization failed: {str(e)}")
64
+ self.text_generator = None
65
+
66
+ # Skip the StableDiffusion model initialization as it requires additional setup
67
+ self.image_model = None
68
+
69
+ # Initialize stability API attribute
70
+ self.stability_api = None
71
+
72
  except Exception as e:
73
  self.logger.error(f"Model initialization failed: {str(e)}")
74
+ # Don't raise exception, allow initialization with degraded functionality
75
+ pass
76
 
77
  def setup_workspace(self):
78
  """Set up working directory and resources"""