Narendra9009 commited on
Commit
a665177
·
1 Parent(s): 6266308

removed unneccesary routes

Browse files
__pycache__/main.cpython-313.pyc CHANGED
Binary files a/__pycache__/main.cpython-313.pyc and b/__pycache__/main.cpython-313.pyc differ
 
main.py CHANGED
@@ -34,69 +34,6 @@ async def read_root():
34
  "age": 20,
35
  "Gender": "Male"
36
  }
37
-
38
- @app.post("/getSeg")
39
- async def get_seg(file: UploadFile = File(...)):
40
- print(f'Image received: {file.filename}')
41
-
42
- try:
43
- image_content = await file.read()
44
- if not image_content:
45
- return JSONResponse(content={"error": "Empty file uploaded"}, status_code=400)
46
-
47
- try:
48
- image = Image.open(io.BytesIO(image_content))
49
- except UnidentifiedImageError:
50
- return JSONResponse(content={"error": "Invalid image format"}, status_code=400)
51
-
52
- # If segment_chess_board is async, use `await`, otherwise remove `await`
53
- segmented_image = await segment_chess_board(image)
54
-
55
- if isinstance(segmented_image, dict):
56
- return JSONResponse(content=segmented_image, status_code=400)
57
-
58
- # Save to in-memory bytes
59
- img_bytes = io.BytesIO()
60
- segmented_image.save(img_bytes, format="PNG")
61
- img_bytes.seek(0)
62
-
63
- print("Image successfully processed and returned")
64
- return StreamingResponse(
65
- img_bytes,
66
- media_type="image/png",
67
- headers={"Content-Disposition": "inline; filename=output.png"}
68
- )
69
-
70
-
71
- except Exception as e:
72
- return JSONResponse(content={"error": str(e)}, status_code=500)
73
-
74
-
75
- @app.post("/getCoords")
76
- async def get_coords(file: UploadFile = File(...)):
77
- try:
78
- image_content = await file.read()
79
-
80
- if not image_content:
81
- print("No image found")
82
- return JSONResponse(content={"error": "Empty file uploaded"}, status_code=400)
83
-
84
- try:
85
- image = Image.open(io.BytesIO(image_content))
86
- except UnidentifiedImageError:
87
- return JSONResponse(content={"error": "Invalid image format"}, status_code=400)
88
-
89
- detection_results = await detect_pieces(image)
90
-
91
- if "error" in detection_results:
92
- return JSONResponse(content=detection_results, status_code=400)
93
-
94
- print("Image successfully processed and returned")
95
- return JSONResponse(content={"detections": detection_results}, status_code=200)
96
-
97
- except Exception as e:
98
- print(f"Unexpected error: {str(e)}")
99
- return JSONResponse(content={"error": "Unexpected error occurred", "details": str(e)}, status_code=500)
100
 
101
 
102
  @app.post("/getFen")
 
34
  "age": 20,
35
  "Gender": "Male"
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
 
39
  @app.post("/getFen")
routes/__pycache__/chess_review.cpython-313.pyc ADDED
Binary file (14.2 kB). View file
 
routes/chess_review.py CHANGED
@@ -180,7 +180,7 @@ def analyze_pgn(pgn_file: str) -> Dict:
180
  board.push(move)
181
 
182
  # Analyze position after the move
183
- post_info = engine.analyse(board, chess.engine.Limit(depth=20))
184
  post_eval = post_info["score"].white().score(mate_score=10000) or 0
185
 
186
  # Determine game phase
 
180
  board.push(move)
181
 
182
  # Analyze position after the move
183
+ post_info = engine.analyse(board, limit = chess.engine.Limit(time = 0.3))
184
  post_eval = post_info["score"].white().score(mate_score=10000) or 0
185
 
186
  # Determine game phase