Comments (15)
Did you run convert_tflite.py? The repo doesn't come with the model. I had to download the yolov4 weights and then ran the below command to generate the tflite file. Hope this helps.
python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4.tflite
from tensorflow-yolov4-tflite.
Did you run convert_tflite.py? The repo doesn't come with the model. I had to download the yolov4 weights and then ran the below command to generate the tflite file. Hope this helps.
python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4.tflite
Thank you for your tip ! But the exported yolov4.tflite is 63040 KB. I think this is too large to intergrate into android app, it is not suitable and practical.
from tensorflow-yolov4-tflite.
That's about the size I got. Still less than the 240MB of the original model. You could try changing the optimizes on line 69 of convert_tflite.py from converter.optimizations = [tf.lite.Optimize.DEFAULT] to converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]. Or try tiny the tiny version of YOLO. Not sure if weights are available or you will have to train your own though.
from tensorflow-yolov4-tflite.
That's about the size I got. Still less than the 240MB of the original model. You could try changing the optimizes on line 69 of convert_tflite.py from converter.optimizations = [tf.lite.Optimize.DEFAULT] to converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]. Or try tiny the tiny version of YOLO. Not sure if weights are available or you will have to train your own though.
Is converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
effective for you ? For me, it still export the same big size yolov4.tflite. By the way, i also try the other two command line :
# yolov4 quantize float16
python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4-fp16.tflite --quantize_mode float16
# yolov4 quantize int8
python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4-fp16.tflite --quantize_mode full_int8 --dataset ./coco_dataset/coco/val207.txt
the first command line produce a more big tflite file which is 125,789 KB, the second command line has two errors: one is the --dataset path, another is after corect the dadaset path, the terminal report : RuntimeError: Max and min for dynamic tensors should be recorded during calibration
from tensorflow-yolov4-tflite.
I have not tried optimize for size no. But thought it worth a try since it's an easy change.
Full int8 quantization requires a representative dataset so it can find the full dynamic range of each activation. So you'll need data for that. However, I didn't suggest it for your case as I don't think it will result in a smaller file since all the weights are already 8 bit in the regular tflite file. Full int 8 makes all the activations 8 bit as well, as far as my understanding of it.
from tensorflow-yolov4-tflite.
@hunglc007 Can you update and fix the typo of #convert-to-tflite part
from tensorflow-yolov4-tflite.
I have not tried optimize for size no. But thought it worth a try since it's an easy change.
Full int8 quantization requires a representative dataset so it can find the full dynamic range of each activation. So you'll need data for that. However, I didn't suggest it for your case as I don't think it will result in a smaller file since all the weights are already 8 bit in the regular tflite file. Full int 8 makes all the activations 8 bit as well, as far as my understanding of it.
Yeah, you reminds me ! The following screenshot is the content of representative dataset - val2017.txt. Does it mean in the folder of /media/user/Source/Data/coco_dataset/coco/images/val2017/, i got to have these real images, and what does the subsequent integers mean ?
from tensorflow-yolov4-tflite.
Right, this is the file that points to where the files are located. The integers are the bounding boxes and the object class. I suggest studying on how YOLO works.
There are tools that can help label your own images. Like Vott. Or there are existing labelled data sets.
from tensorflow-yolov4-tflite.
Right, this is the file that points to where the files are located. The integers are the bounding boxes and the object class. I suggest studying on how YOLO works.
There are tools that can help label your own images. Like Vott. Or there are existing labelled data sets.
@sterlingrpi I got it !Thanks !
from tensorflow-yolov4-tflite.
I have not tried optimize for size no. But thought it worth a try since it's an easy change.
Full int8 quantization requires a representative dataset so it can find the full dynamic range of each activation. So you'll need data for that. However, I didn't suggest it for your case as I don't think it will result in a smaller file since all the weights are already 8 bit in the regular tflite file. Full int 8 makes all the activations 8 bit as well, as far as my understanding of it.Yeah, you reminds me ! The following scr
eenshot is the content of representative dataset - val2017.txt. Does it mean in the folder of /media/user/Source/Data/coco_dataset/coco/images/val2017/, i got to have these real images, and what does the subsequent integers mean ?
u can chage func def representative_data_gen in convert_tflite.py file
fimage = open(FLAGS.dataset).read().split()
for input_value in range(1000):
path = "path_to_image/"+fimage[input_value]
if os.path.exists(path):
print(fimage[input_value])
original_image=cv2.imread(path)
original_image = cv2.cvtColor(original_image, cv2.COLOR_BGR2RGB)
image_data = utils.image_preporcess(np.copy(original_image), [FLAGS.input_size, FLAGS.input_size])
img_in = image_data[np.newaxis, ...].astype(np.float32)
print(input_value)
yield [img_in]
else:
print(path)
continue
from tensorflow-yolov4-tflite.
@sterlingrpi where did you put the .tflite file?
from tensorflow-yolov4-tflite.
@sterlingrpi where did you put the .tflite file?
I left it in the default data directory
from tensorflow-yolov4-tflite.
@sterlingrpi how does it perform on your phone? I installed on Google Pixel XL, it painfully slow
from tensorflow-yolov4-tflite.
@EuphoriaCelestial haven't tried on a phone. I'm running on RPi. But I can concur it is slow. You can try full int8 quantization and/or YOLO tiny. We are working on this in another thread. But it's a process #53
from tensorflow-yolov4-tflite.
我没有尝试优化尺寸。但是认为这是值得尝试的,因为这是一个容易的更改。
完整的int8量化需要一个有代表性的数据集,因此它可以找到每个激活的完整动态范围。因此,您将需要数据。但是,我没有针对您的情况提出建议,因为我认为这不会导致文件变小,因为常规tflite文件中的所有权重已为8位。据我所知,Full int 8也使所有激活都为8位。是的,你提醒我!以下屏幕截图是代表性数据集的内容-val2017.txt。这是否意味着在/ media / user / Source / Data / coco_dataset / coco / images / val2017 /的文件夹中,我必须拥有这些真实图像,并且随后的整数是什么意思?
I also met the same problem. How did you solve it? thank you
from tensorflow-yolov4-tflite.
Related Issues (20)
- geYOLOv4 multiple bounding box for the same object
- Is there a way to do object detection in videos(.mp4) on Android?
- ValueError: cannot reshape array of size 92951 into shape (256,128,3,3) HOT 2
- InvalidArgumentError: scores has incompatible shape [Op:CombinedNonMaxSuppression]
- Bounding boxes not showing when using tensorflow-gpu HOT 1
- Is it possible to deploy on this app yolov5 model ?
- Errors with converted yolov4 model on Android Studio
- TensorRT
- weights not saved properly HOT 1
- yolo v4 -tiny weights conversion to .pb HOT 1
- I really want to convert .weights into a .tflite model but nothing works HOT 3
- Duplicate node name in graph: 'packed'
- Changing The Loss Function
- ValueError: not enough values to unpack (expected 5, got 0)
- Caused by: java.lang.IllegalArgumentException: Cannot copy from a TensorFlowLite tensor (StatefulPartitionedCall:0) with shape [1, 10647, 7] to a Java object with shape [1, 13, 13, 35].
- Weights are 404 on Google Drive HOT 1
- Problem when quantizing models
- Detect button crash
- ValueError: Mmap of '31' at offset '0' failed with error '19'.
- Value unexpected in model graph
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflow-yolov4-tflite.