benedetta commited on
Commit
0a1fc1e
·
1 Parent(s): fc0e609

fix error

Browse files
Files changed (2) hide show
  1. README.md +10 -0
  2. sam_server.py +11 -11
README.md CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  # SAM Backend per Segmentazione Immagini
2
 
3
  Server FastAPI per la segmentazione di immagini usando SAM (Segment Anything Model) di Meta.
 
1
+ ---
2
+ title: SAM Server
3
+ emoji: 🖼️
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
  # SAM Backend per Segmentazione Immagini
12
 
13
  Server FastAPI per la segmentazione di immagini usando SAM (Segment Anything Model) di Meta.
sam_server.py CHANGED
@@ -33,7 +33,13 @@ app = FastAPI(
33
  # Enable CORS for Next.js frontend
34
  app.add_middleware(
35
  CORSMiddleware,
36
- allow_origins=["http://localhost:3000", "http://127.0.0.1:3000", "https://data-visualization-red-six.vercel.app/"],
 
 
 
 
 
 
37
  allow_credentials=True,
38
  allow_methods=["*"],
39
  allow_headers=["*"],
@@ -485,10 +491,10 @@ async def get_cached_masks():
485
 
486
  if __name__ == "__main__":
487
  import uvicorn
488
-
489
  # Create checkpoints directory
490
  CHECKPOINTS_DIR.mkdir(exist_ok=True)
491
-
492
  print(f"Checkpoints directory: {CHECKPOINTS_DIR}")
493
  print("Download SAM model checkpoints from:")
494
  print("https://github.com/facebookresearch/segment-anything#model-checkpoints")
@@ -499,12 +505,6 @@ if __name__ == "__main__":
499
  status = "✓" if path.exists() else "✗"
500
  print(f" {status} {model_type}: {checkpoint}")
501
  print()
502
-
503
- if __name__ == "__main__":
504
- import uvicorn
505
- import os
506
-
507
- port = int(os.environ.get("PORT", 7860))
508
-
509
- uvicorn.run(app, host="0.0.0.0", port=port)
510
 
 
 
 
33
  # Enable CORS for Next.js frontend
34
  app.add_middleware(
35
  CORSMiddleware,
36
+ allow_origins=[
37
+ "http://localhost:3000",
38
+ "http://127.0.0.1:3000",
39
+ "https://data-visualization-red-six.vercel.app",
40
+ "https://benny2199-sam-server.hf.space",
41
+ "*",
42
+ ],
43
  allow_credentials=True,
44
  allow_methods=["*"],
45
  allow_headers=["*"],
 
491
 
492
  if __name__ == "__main__":
493
  import uvicorn
494
+
495
  # Create checkpoints directory
496
  CHECKPOINTS_DIR.mkdir(exist_ok=True)
497
+
498
  print(f"Checkpoints directory: {CHECKPOINTS_DIR}")
499
  print("Download SAM model checkpoints from:")
500
  print("https://github.com/facebookresearch/segment-anything#model-checkpoints")
 
505
  status = "✓" if path.exists() else "✗"
506
  print(f" {status} {model_type}: {checkpoint}")
507
  print()
 
 
 
 
 
 
 
 
508
 
509
+ port = int(os.environ.get("PORT", 7860))
510
+ uvicorn.run(app, host="0.0.0.0", port=port)