Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.chaquo.python.PyException: Exception: [Errno 30] Read-only file system: '../assets'. Cache may be out of date, try force_reload=True or see https://github.com/ultralytics/yolov5/issues/36 for help #824

Closed
iammohit1311 opened this issue Mar 19, 2023 · 4 comments

Comments

@iammohit1311
Copy link

iammohit1311 commented Mar 19, 2023

I am trying to load my custom YOLOv5 model using PyTorch. Then run predictions and save cropped results. However, it seems Chaquopy is not able to read my model named 'best.pt' present in 'assets' directory @mhsmith

Chaquopy version

id 'com.chaquo.python' version '14.0.2' apply false

Relevant parts of my code

This is what I have in my python file:

import torch
model = torch.hub.load('ultralytics/yolov5', 'custom', path='../assets/best.pt', force_reload=True)
im = img_url  

# Inference
results = model(im)

# Results
results.crop(save_dir="./result")  # or .show(), .save(), .crop(), .pandas(), etc.

Describe your issue

Stack trace
W/python.stderr: �[31m�[1mrequirements:�[0m YOLOv5 requirement "matplotlib>=3.2.2" not found, attempting AutoUpdate...
W/python.stderr: �[31m�[1mrequirements:�[0m ❌ Command 'pip install "matplotlib>=3.2.2" ' returned non-zero exit status 127.
W/python.stderr: YOLOv5 🚀 2023-3-19 Python-3.8.16 torch-1.8.1 CPU
W/python.stderr:
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.firebasetest, PID: 12820
com.chaquo.python.PyException: Exception: [Errno 30] Read-only file system: '../assets'. Cache may be out of date, try force_reload=True or see https://github.com/ultralytics/yolov5/issues/36 for help.
at .hubconf.py._create(hubconf.py:78)
at .hubconf.py.custom(hubconf.py:83)
at .torch.hub._load_local(hub.py:368)
at .torch.hub.load(hub.py:339)
at .yoloscript.main(yoloscript.py:29)
at .chaquopy_java.call(chaquopy_java.pyx:354)
at .chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:326)
at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
at com.example.firebasetest.MainActivity.detect(MainActivity.kt:113)
at com.example.firebasetest.MainActivity$uploadFile$1$1$1.invoke(MainActivity.kt:98)
at com.example.firebasetest.MainActivity$uploadFile$1$1$1.invoke(MainActivity.kt:95)
at com.example.firebasetest.MainActivity$uploadFile$1$1.invoke$lambda$0(MainActivity.kt:95)
at com.example.firebasetest.MainActivity$uploadFile$1$1.$r8$lambda$AUdobY3vHU2uvJPt71kXe-c4xGs(Unknown Source:0)
at com.example.firebasetest.MainActivity$uploadFile$1$1$$ExternalSyntheticLambda0.onSuccess(Unknown Source:2)
at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process: Sending signal. PID: 12820 SIG: 9

@iammohit1311
Copy link
Author

@mhsmith

@mhsmith
Copy link
Member

mhsmith commented Mar 20, 2023

The current directory could be anywhere on Android, so you must use absolute paths. See the FAQ sections "Read files in Python" and "Write files in Python".

@mhsmith mhsmith closed this as completed Mar 20, 2023
@Dev180399
Copy link

@iammohit1311 i am getting the same issue........ is your issue resolved? are you able to use Yolov5 model

@mhsmith
Copy link
Member

mhsmith commented Dec 11, 2023

Just follow the instructions in the FAQ, as linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants