Spaces:
Runtime error
Runtime error
Update sample.py
Browse files
sample.py
CHANGED
@@ -13,7 +13,7 @@ def load_model():
|
|
13 |
return model
|
14 |
|
15 |
# Define YOLO processing function
|
16 |
-
def process_image(image
|
17 |
# Preprocess the image
|
18 |
preprocess = transforms.Compose([
|
19 |
transforms.Resize((416, 416)),
|
@@ -23,17 +23,17 @@ def process_image(image, model):
|
|
23 |
input_tensor = preprocess(image)
|
24 |
input_batch = input_tensor.unsqueeze(0)
|
25 |
|
26 |
-
# Perform inference
|
27 |
-
with torch.no_grad():
|
28 |
-
|
29 |
|
30 |
-
# Post-process the output (e.g., draw bounding boxes)
|
31 |
-
# Replace this with your post-processing code
|
32 |
|
33 |
-
# Convert tensor to PIL Image
|
34 |
-
output_image = transforms.ToPILImage()(output[0].cpu().squeeze())
|
35 |
|
36 |
-
return
|
37 |
|
38 |
# Main Streamlit code
|
39 |
def main():
|
@@ -50,7 +50,7 @@ def main():
|
|
50 |
image = Image.open(uploaded_file)
|
51 |
st.image(image, caption='Original Image', use_column_width=True)
|
52 |
|
53 |
-
output =
|
54 |
output_image = Image.fromarray(np.array(output))
|
55 |
st.image(output_image, caption='Processed Image', use_column_width=True)
|
56 |
|
|
|
13 |
return model
|
14 |
|
15 |
# Define YOLO processing function
|
16 |
+
def process_image(image):
|
17 |
# Preprocess the image
|
18 |
preprocess = transforms.Compose([
|
19 |
transforms.Resize((416, 416)),
|
|
|
23 |
input_tensor = preprocess(image)
|
24 |
input_batch = input_tensor.unsqueeze(0)
|
25 |
|
26 |
+
# # Perform inference
|
27 |
+
# with torch.no_grad():
|
28 |
+
# output = model(input_batch)
|
29 |
|
30 |
+
# # Post-process the output (e.g., draw bounding boxes)
|
31 |
+
# # Replace this with your post-processing code
|
32 |
|
33 |
+
# # Convert tensor to PIL Image
|
34 |
+
# output_image = transforms.ToPILImage()(output[0].cpu().squeeze())
|
35 |
|
36 |
+
return input_batch
|
37 |
|
38 |
# Main Streamlit code
|
39 |
def main():
|
|
|
50 |
image = Image.open(uploaded_file)
|
51 |
st.image(image, caption='Original Image', use_column_width=True)
|
52 |
|
53 |
+
output = process_image(image)
|
54 |
output_image = Image.fromarray(np.array(output))
|
55 |
st.image(output_image, caption='Processed Image', use_column_width=True)
|
56 |
|