jkorstad commited on
Commit
8fd199a
·
verified ·
1 Parent(s): 03e7772

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -5,12 +5,10 @@ import time
5
  import os
6
  import shutil
7
  from gradio_client import Client, handle_file
8
-
9
- # Ensure /data/ directory exists
10
- os.makedirs('/data', exist_ok=True)
11
 
12
  # Database setup
13
- conn = sqlite3.connect('/data/jobs.db', check_same_thread=False)
14
  c = conn.cursor()
15
  c.execute('''CREATE TABLE IF NOT EXISTS jobs
16
  (id INTEGER PRIMARY KEY, image_path TEXT, job_id TEXT, status TEXT, output_path TEXT)''')
@@ -19,6 +17,8 @@ conn.commit()
19
  # TRELLIS API client
20
  trellis_client = Client("jkorstad/TRELLIS")
21
 
 
 
22
  # Processing logic with three-step TRELLIS workflow
23
  def process_job(job_id):
24
  try:
@@ -63,8 +63,8 @@ def process_job(job_id):
63
  glb_path = glb_result[0] # First element is the GLB filepath
64
 
65
  # Move GLB to persistent storage
66
- output_path = f'/data/outputs/result_{job_id}.glb'
67
- os.makedirs('/data/outputs', exist_ok=True)
68
  shutil.move(glb_path, output_path)
69
 
70
  # Update job status
@@ -84,8 +84,8 @@ def submit_images(files):
84
  c.execute("INSERT INTO jobs (status) VALUES ('submitted')")
85
  job_id = c.lastrowid
86
  conn.commit()
87
- image_path = f'/data/inputs/input_{job_id}.jpg'
88
- os.makedirs('/data/inputs', exist_ok=True)
89
  shutil.copy(file.name, image_path)
90
  c.execute("UPDATE jobs SET image_path=? WHERE id=?", (image_path, job_id))
91
  conn.commit()
 
5
  import os
6
  import shutil
7
  from gradio_client import Client, handle_file
8
+ # import spaces
 
 
9
 
10
  # Database setup
11
+ conn = sqlite3.connect('/tmp/jobs.db', check_same_thread=False)
12
  c = conn.cursor()
13
  c.execute('''CREATE TABLE IF NOT EXISTS jobs
14
  (id INTEGER PRIMARY KEY, image_path TEXT, job_id TEXT, status TEXT, output_path TEXT)''')
 
17
  # TRELLIS API client
18
  trellis_client = Client("jkorstad/TRELLIS")
19
 
20
+
21
+ # @spaces.GPU
22
  # Processing logic with three-step TRELLIS workflow
23
  def process_job(job_id):
24
  try:
 
63
  glb_path = glb_result[0] # First element is the GLB filepath
64
 
65
  # Move GLB to persistent storage
66
+ output_path = f'/tmp/outputs/result_{job_id}.glb'
67
+ os.makedirs('/tmp/outputs', exist_ok=True)
68
  shutil.move(glb_path, output_path)
69
 
70
  # Update job status
 
84
  c.execute("INSERT INTO jobs (status) VALUES ('submitted')")
85
  job_id = c.lastrowid
86
  conn.commit()
87
+ image_path = f'/tmp/inputs/input_{job_id}.jpg'
88
+ os.makedirs('/tmp/inputs', exist_ok=True)
89
  shutil.copy(file.name, image_path)
90
  c.execute("UPDATE jobs SET image_path=? WHERE id=?", (image_path, job_id))
91
  conn.commit()