Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,11 +100,11 @@ with col2:
|
|
| 100 |
|
| 101 |
with col3:
|
| 102 |
st.header('details')
|
|
|
|
| 103 |
if gibsOk:
|
| 104 |
if clicked == -1:
|
| 105 |
clicked = 0
|
| 106 |
detectorForContents = pipeline("object-detection", model="sergioska/yolo-finetuned-flyers-content")
|
| 107 |
-
st.write(imagesForOpen[clicked])
|
| 108 |
imageForDetails = Image.open(imagesForOpen[clicked])
|
| 109 |
outputImageForDetails = np.array(imageForDetails)
|
| 110 |
predictionsForDetails = detectorForContents(
|
|
@@ -112,14 +112,16 @@ with col3:
|
|
| 112 |
candidate_labels=['title', 'price']
|
| 113 |
)
|
| 114 |
drawForDetails = ImageDraw.Draw(imageForDetails)
|
|
|
|
| 115 |
for predictionsForDetail in predictionsForDetails:
|
| 116 |
box = predictionsForDetail["box"]
|
| 117 |
label = predictionsForDetail["label"]
|
| 118 |
score = predictionsForDetail["score"]
|
| 119 |
|
| 120 |
xmin, ymin, xmax, ymax = box.values()
|
| 121 |
-
drawForDetails.rectangle((xmin, ymin, xmax, ymax), outline=
|
| 122 |
drawForDetails.text((xmin, ymin), f"{label}: {round(score,5)}", fill="white")
|
|
|
|
| 123 |
|
| 124 |
st.image(imageForDetails)
|
| 125 |
st.write(predictionsForDetails)
|
|
|
|
| 100 |
|
| 101 |
with col3:
|
| 102 |
st.header('details')
|
| 103 |
+
colors = ["red", "yellow", "purple", "blue", "green"]
|
| 104 |
if gibsOk:
|
| 105 |
if clicked == -1:
|
| 106 |
clicked = 0
|
| 107 |
detectorForContents = pipeline("object-detection", model="sergioska/yolo-finetuned-flyers-content")
|
|
|
|
| 108 |
imageForDetails = Image.open(imagesForOpen[clicked])
|
| 109 |
outputImageForDetails = np.array(imageForDetails)
|
| 110 |
predictionsForDetails = detectorForContents(
|
|
|
|
| 112 |
candidate_labels=['title', 'price']
|
| 113 |
)
|
| 114 |
drawForDetails = ImageDraw.Draw(imageForDetails)
|
| 115 |
+
c = 0
|
| 116 |
for predictionsForDetail in predictionsForDetails:
|
| 117 |
box = predictionsForDetail["box"]
|
| 118 |
label = predictionsForDetail["label"]
|
| 119 |
score = predictionsForDetail["score"]
|
| 120 |
|
| 121 |
xmin, ymin, xmax, ymax = box.values()
|
| 122 |
+
drawForDetails.rectangle((xmin, ymin, xmax, ymax), outline=colors[c], width=5)
|
| 123 |
drawForDetails.text((xmin, ymin), f"{label}: {round(score,5)}", fill="white")
|
| 124 |
+
c += 1
|
| 125 |
|
| 126 |
st.image(imageForDetails)
|
| 127 |
st.write(predictionsForDetails)
|