Closed Moheeb77 closed 1 year ago
Your question seems to be missing weights, you need to create directory and put weights.
if you need to use the ensemble method:
model = "weights/best.pt"
changed to
model = ["weights/best1.pt", "weights/best2.pt", "weights/best3.pt"]
Thank you for your replay, It would be appreciated for demonstrating a fully working example with simple data to see how the solution work. I created a directory and inserted the best.pt file in it but I got another error when I run the application to test it.
Model Summary: 768 layers, 29113130 parameters, 0 gradients Traceback (most recent call last): File ".local/lib/python3.8/site-packages/gradio/routes.py", line 384, in run_predict output = await app.get_blocks().process_api( File ".local/lib/python3.8/site-packages/gradio/blocks.py", line 1032, in process_api result = await self.call_function( File ".local/lib/python3.8/site-packages/gradio/blocks.py", line 844, in call_function prediction = await anyio.to_thread.run_sync( File ".local/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File ".local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread return await future File ".local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run result = context.run(func, *args) File "ui.py", line 72, in detect dataset = LoadImages(source, img_size=imgsz, auto_size=64) File "fracture-Detection/utils/datasets.py", line 158, in init raise Exception('ERROR: %s does not exist' % p) Exception: ERROR: fracture-Detection/inference does not exist
Thank you for spotting this error. This error is because the default directory is not set correctly.
# incorrect
#parser.add_argument('--source', type=str, default='inference/', help='source')
# correct
parser.add_argument('--source', type=str, default='example/', help='source')
I have fixed this, you can change it manually or download a new file.
The path of the detected image is ./runs/detect/exp
After correcting this error I got another one. It seems to be that the code is not compatible with new version of torch. I have modified the file "upsampling.py" line 157 as follow and it worked without any problem
./lib/python3.8/site-packages/torch/nn/modules/upsampling.py
# return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
# recompute_scale_factor=self.recompute_scale_factor)
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners)
Fusing layers... Model Summary: 768 layers, 29113130 parameters, 0 gradients Traceback (most recent call last): File ".local/lib/python3.8/site-packages/gradio/routes.py", line 384, in run_predict output = await app.get_blocks().process_api( File ".local/lib/python3.8/site-packages/gradio/blocks.py", line 1032, in process_api result = await self.call_function( File ".local/lib/python3.8/site-packages/gradio/blocks.py", line 844, in call_function prediction = await anyio.to_thread.run_sync( File ".local/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File ".local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread return await future File ".local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run result = context.run(func, args) File "ui.py", line 100, in detect pred = model(img, augment=opt.augment)[0] File ".local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(input, *kwargs) File "fracture-Detection/models/yolo.py", line 177, in forward return self.forward_once(x, profile) # single-scale inference, train File "fracture-Detection/models/yolo.py", line 193, in forward_once x = m(x) # run File ".local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(input, **kwargs) File ".local/lib/python3.8/site-packages/torch/nn/modules/upsampling.py", line 157, in forward recompute_scale_factor=self.recompute_scale_factor) File ".local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1269, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
This is the output result
My test environment is as follows, and this error does not occur.
I think it has something to do with the version of pytorch, I have updated the environment requirements. Thank you for your questions and solutions!
Hi Could you please add some sample data to check the application? I get error when running python ui.py and click on submit
FileNotFoundError: [Errno 2] No such file or directory: 'weights/best.pt'
Regards,