ArthurGamaJorge commited on
Commit
c4f2cbd
·
1 Parent(s): 5b1befc

Atualizar permissões

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -51,7 +51,8 @@ async def upload_image(file: UploadFile = File(...)):
51
  print("Detecting...")
52
 
53
  image_uuid = str(uuid.uuid4())
54
- image_path = f"{image_uuid}.png"
 
55
 
56
  contents = await file.read()
57
  with open(image_path, "wb") as f:
@@ -88,6 +89,7 @@ async def upload_image(file: UploadFile = File(...)):
88
  "original_height": height
89
  }
90
  })
 
91
  os.remove(image_path)
92
 
93
  intensity_score = caculateIntensity(detections)
@@ -102,6 +104,4 @@ async def upload_image(file: UploadFile = File(...)):
102
  except Exception as e:
103
  if os.path.exists(image_path):
104
  os.remove(image_path)
105
-
106
  return JSONResponse(status_code=500, content={"error": str(e)})
107
-
 
51
  print("Detecting...")
52
 
53
  image_uuid = str(uuid.uuid4())
54
+ temp_dir = "/tmp"
55
+ image_path = os.path.join(temp_dir, f"{image_uuid}.png")
56
 
57
  contents = await file.read()
58
  with open(image_path, "wb") as f:
 
89
  "original_height": height
90
  }
91
  })
92
+
93
  os.remove(image_path)
94
 
95
  intensity_score = caculateIntensity(detections)
 
104
  except Exception as e:
105
  if os.path.exists(image_path):
106
  os.remove(image_path)
 
107
  return JSONResponse(status_code=500, content={"error": str(e)})