Sanshruth commited on
Commit
09557c9
1 Parent(s): eb42d16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -1,20 +1,27 @@
1
  import zipfile
2
- import subprocess
3
  def unzip_content():
4
  try:
 
5
  print("Attempting to unzip content using Python...")
6
  with zipfile.ZipFile('./content.zip', 'r') as zip_ref:
7
  zip_ref.extractall('.')
8
  except Exception as e:
9
  print(f"Python unzip failed: {str(e)}")
10
  try:
 
11
  print("Attempting to unzip content using system command...")
12
  subprocess.run(['unzip', '-o', './content.zip'], check=True)
13
  except Exception as e:
14
  print(f"System unzip failed: {str(e)}")
15
  raise Exception("Failed to unzip content using both methods")
16
  print("Content successfully unzipped!")
17
- import subprocess
 
 
 
 
 
 
18
  import gradio as gr
19
  import numpy as np
20
  import torch
@@ -28,18 +35,19 @@ from omegaconf import OmegaConf
28
  from CLIP import clip
29
  import os
30
  import sys
31
- import tempfile
32
- import io
33
- from pathlib import Path
34
- from PIL import Image
35
- import cv2
36
- import imageio
37
 
38
- # Add taming transformers path
 
 
39
  taming_path = os.path.join(os.getcwd(), 'taming-transformers')
40
  sys.path.append(taming_path)
41
  from taming.models.vqgan import VQModel
42
 
 
 
 
 
 
43
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
44
 
45
 
 
1
  import zipfile
 
2
  def unzip_content():
3
  try:
4
+ # First try using Python's zipfile
5
  print("Attempting to unzip content using Python...")
6
  with zipfile.ZipFile('./content.zip', 'r') as zip_ref:
7
  zip_ref.extractall('.')
8
  except Exception as e:
9
  print(f"Python unzip failed: {str(e)}")
10
  try:
11
+ # Fallback to system unzip command
12
  print("Attempting to unzip content using system command...")
13
  subprocess.run(['unzip', '-o', './content.zip'], check=True)
14
  except Exception as e:
15
  print(f"System unzip failed: {str(e)}")
16
  raise Exception("Failed to unzip content using both methods")
17
  print("Content successfully unzipped!")
18
+
19
+ # Try to unzip content at startup
20
+ try:
21
+ unzip_content()
22
+ except Exception as e:
23
+ print(f"Warning: Could not unzip content: {str(e)}")
24
+
25
  import gradio as gr
26
  import numpy as np
27
  import torch
 
35
  from CLIP import clip
36
  import os
37
  import sys
 
 
 
 
 
 
38
 
39
+ #os.chdir('./taming-transformers')
40
+ #from taming.models.vqgan import VQModel
41
+ #os.chdir('..')
42
  taming_path = os.path.join(os.getcwd(), 'taming-transformers')
43
  sys.path.append(taming_path)
44
  from taming.models.vqgan import VQModel
45
 
46
+
47
+ from PIL import Image
48
+ import cv2
49
+ import imageio
50
+
51
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
52
 
53