Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -214,9 +214,28 @@ checkpoint = torch.load("Model_IV.pt")
|
|
214 |
# model.load_state_dict(checkpoint) # Load the saved weights
|
215 |
# model.eval() # Set the model to evaluation mode
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
# Define preprocessing
|
222 |
transform = T.Compose([
|
@@ -234,9 +253,8 @@ def predict(image):
|
|
234 |
|
235 |
# Process output (adjust based on your model's format)
|
236 |
# return output # or post-process the results as needed
|
237 |
-
results = model(image)
|
238 |
-
|
239 |
-
annotated_img = results.render()[0]
|
240 |
return annotated_img
|
241 |
|
242 |
# Gradio interface
|
|
|
214 |
# model.load_state_dict(checkpoint) # Load the saved weights
|
215 |
# model.eval() # Set the model to evaluation mode
|
216 |
|
217 |
+
# from ultralytics import settings
|
218 |
+
# # Update multiple settings
|
219 |
+
# settings.update({
|
220 |
+
# "names": {0: 'A', 1: 'B',
|
221 |
+
# 2: 'C', 3: 'D',
|
222 |
+
# 4: 'E', 5: 'F',
|
223 |
+
# 6: 'G', 7: 'H',
|
224 |
+
# 8: 'I', 9: 'J',
|
225 |
+
# 10: 'K', 11: 'L',
|
226 |
+
# 12: 'M', 13: 'N',
|
227 |
+
# 14: 'O', 15: 'P',
|
228 |
+
# 16: 'Q', 17: 'R',
|
229 |
+
# 18: 'S', 19: 'T',
|
230 |
+
# 20: 'U', 21: 'V',
|
231 |
+
# 22: 'W', 23: 'X',
|
232 |
+
# 24: 'Y', 25: 'Z'},
|
233 |
+
# "tensorboard": False
|
234 |
+
# })
|
235 |
+
|
236 |
+
# print(type(checkpoint))
|
237 |
+
# if isinstance(checkpoint, dict):
|
238 |
+
# print(checkpoint.keys())
|
239 |
|
240 |
# Define preprocessing
|
241 |
transform = T.Compose([
|
|
|
253 |
|
254 |
# Process output (adjust based on your model's format)
|
255 |
# return output # or post-process the results as needed
|
256 |
+
results = model(image, save=True)
|
257 |
+
annotated_img = Image.load("")
|
|
|
258 |
return annotated_img
|
259 |
|
260 |
# Gradio interface
|