Spaces:
Runtime error
Runtime error
add a button to apply tags
Browse files
app.py
CHANGED
|
@@ -44,13 +44,13 @@ if uploaded_image_zero_file is not None:
|
|
| 44 |
st.image(outputImage)
|
| 45 |
|
| 46 |
if st.button('apply tag'):
|
| 47 |
-
tags = [
|
| 48 |
inputs = processor(text=tags, images=image, return_tensors="pt")
|
| 49 |
outputs = model(**inputs)
|
| 50 |
target_sizes = torch.Tensor([image.size[::-1]])
|
| 51 |
results = processor.post_process_object_detection(outputs=outputs, threshold=0.1, target_sizes=target_sizes)
|
| 52 |
i = 0 # Retrieve predictions for the first image for the corresponding text queries
|
| 53 |
-
text =
|
| 54 |
boxes, scores, labels = results[i]["boxes"], results[i]["scores"], results[i]["labels"]
|
| 55 |
st.write(results)
|
| 56 |
# Print detected objects and rescaled box coordinates
|
|
|
|
| 44 |
st.image(outputImage)
|
| 45 |
|
| 46 |
if st.button('apply tag'):
|
| 47 |
+
tags = [['eggs', 'apple', 'pear']]
|
| 48 |
inputs = processor(text=tags, images=image, return_tensors="pt")
|
| 49 |
outputs = model(**inputs)
|
| 50 |
target_sizes = torch.Tensor([image.size[::-1]])
|
| 51 |
results = processor.post_process_object_detection(outputs=outputs, threshold=0.1, target_sizes=target_sizes)
|
| 52 |
i = 0 # Retrieve predictions for the first image for the corresponding text queries
|
| 53 |
+
text = tags[i]
|
| 54 |
boxes, scores, labels = results[i]["boxes"], results[i]["scores"], results[i]["labels"]
|
| 55 |
st.write(results)
|
| 56 |
# Print detected objects and rescaled box coordinates
|