rootglitch commited on
Commit
413b0e5
·
1 Parent(s): 1354e82

Added tmp/images to store images

Browse files
Files changed (2) hide show
  1. app.py +12 -2
  2. tmp/tmp.txt +0 -0
app.py CHANGED
@@ -11,7 +11,6 @@ import requests
11
  from typing import Dict, List, Tuple, Union, Optional
12
 
13
  # dotenv.load_dotenv()
14
- FAL_KEY = os.getenv("FAL_KEY")
15
 
16
  # Configure logging
17
  logging.basicConfig(
@@ -55,6 +54,8 @@ CONFIG_FILE = 'GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py'
55
  GROUNDINGDINO_CHECKPOINT = "groundingdino_swint_ogc.pth"
56
  SAM_CHECKPOINT = 'sam_hq_vit_l.pth'
57
  OUTPUT_DIR = "outputs"
 
 
58
 
59
  # Global variables for model caching
60
  _models = {
@@ -326,8 +327,17 @@ def run_grounded_sam(
326
  else:
327
  return [Image.new('RGB', (400, 300), color='gray'), Image.new('RGBA', (400, 300), color=(0, 0, 0, 0))]
328
 
 
 
 
 
 
 
 
 
329
  def generate_ai_bg(input_img, prompt):
330
- hf_input_img = 'https://huggingface.co/spaces/rootglitch/CarVizGradioDemo01/'+input_img
 
331
  handler = fal_client.submit(
332
  "fal-ai/iclight-v2",
333
  arguments={
 
11
  from typing import Dict, List, Tuple, Union, Optional
12
 
13
  # dotenv.load_dotenv()
 
14
 
15
  # Configure logging
16
  logging.basicConfig(
 
54
  GROUNDINGDINO_CHECKPOINT = "groundingdino_swint_ogc.pth"
55
  SAM_CHECKPOINT = 'sam_hq_vit_l.pth'
56
  OUTPUT_DIR = "outputs"
57
+ FAL_KEY = os.getenv("FAL_KEY")
58
+ UPLOAD_DIR = "/tmp/images"
59
 
60
  # Global variables for model caching
61
  _models = {
 
327
  else:
328
  return [Image.new('RGB', (400, 300), color='gray'), Image.new('RGBA', (400, 300), color=(0, 0, 0, 0))]
329
 
330
+ def upload_file(file: UploadFile):
331
+ file_path = os.path.join(UPLOAD_DIR, file.filename)
332
+ with open(file_path, "wb") as buffer:
333
+ shutil.copyfileobj(file.file, buffer)
334
+
335
+ # Return URL
336
+ return {"url": f"https://huggingface.co/spaces/rootglitch/CarVizGradioDemo01/{file_path}"}
337
+
338
  def generate_ai_bg(input_img, prompt):
339
+ hf_input_img = upload_file(input_img)["url"]
340
+
341
  handler = fal_client.submit(
342
  "fal-ai/iclight-v2",
343
  arguments={
tmp/tmp.txt ADDED
File without changes