Spaces:
Running
Running
wjbmattingly
commited on
Commit
•
15f423a
1
Parent(s):
cf28c32
removed device
Browse files- app/main.py +1 -1
- data/ms.jpg +0 -0
- send_image.py +27 -0
app/main.py
CHANGED
@@ -29,7 +29,7 @@ async def detect_lines(file: UploadFile = File(...)):
|
|
29 |
lines_json_path = os.path.join(temp_dir, "lines.json")
|
30 |
|
31 |
# Run Kraken for line detection
|
32 |
-
kraken_command = f"kraken -i {temp_file_path} {lines_json_path} segment -bl
|
33 |
subprocess.run(kraken_command, shell=True, check=True)
|
34 |
|
35 |
# Load the lines from the JSON file
|
|
|
29 |
lines_json_path = os.path.join(temp_dir, "lines.json")
|
30 |
|
31 |
# Run Kraken for line detection
|
32 |
+
kraken_command = f"kraken -i {temp_file_path} {lines_json_path} segment -bl"
|
33 |
subprocess.run(kraken_command, shell=True, check=True)
|
34 |
|
35 |
# Load the lines from the JSON file
|
data/ms.jpg
ADDED
send_image.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import os
|
3 |
+
|
4 |
+
# API endpoint
|
5 |
+
url = "https://wjbmattingly-kraken-api.hf.space/detect_lines"
|
6 |
+
|
7 |
+
# Path to the image file
|
8 |
+
image_path = os.path.join("data", "ms.jpg")
|
9 |
+
|
10 |
+
# Prepare the file for upload
|
11 |
+
files = {'file': ('ms.jpg', open(image_path, 'rb'), 'image/jpeg')}
|
12 |
+
|
13 |
+
# Send the POST request
|
14 |
+
response = requests.post(url, files=files)
|
15 |
+
|
16 |
+
# Check if the request was successful
|
17 |
+
if response.status_code == 200:
|
18 |
+
# Parse the JSON response
|
19 |
+
result = response.json()
|
20 |
+
|
21 |
+
# Print the detected lines
|
22 |
+
print("Detected lines:")
|
23 |
+
for line in result['lines']:
|
24 |
+
print(f"Line: {line}")
|
25 |
+
else:
|
26 |
+
print(f"Error: {response.status_code}")
|
27 |
+
print(response.text)
|