-
Notifications
You must be signed in to change notification settings - Fork 38
Квантизация PaddlePaddle #575
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
base: master
Are you sure you want to change the base?
Квантизация PaddlePaddle #575
Conversation
THREAD = 16 | ||
BUF_SIZE = 10240 | ||
|
||
DATA_DIR = r'D:\ws\dl-benchmark\imagenet' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По коду не должно быть статических путей.
return data | ||
|
||
def __len__(self): | ||
return len(self.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Слишком много всего в одном скрипте. Предлагаю разделить хотя бы на два: 1 - то, что имеет отношение непосредственно к обработке изображений, 2 - то, что имеет отношение к загрузке данных и последующей обработке с использование 1.
…quantization_paddlepaddle
requirements_frameworks.txt
Outdated
@@ -7,7 +7,7 @@ torchvision==0.14.1+cu117 | |||
--extra-index-url https://download.pytorch.org/whl/cu117 | |||
|
|||
onnxruntime | |||
apache-tvm==0.14.dev170 | |||
# apache-tvm==0.14.dev170 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Твм нужен для тестирования, поэтому нельзя его просто отключать.
|
||
def crop_image(img, target_size, center): | ||
width, height = img.size | ||
size = target_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По коду не вижу необходимости создавать локальную переменную size, можно использовать target_size
img = ops[1](img) | ||
img = ops[2](img) | ||
|
||
return img |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В всех функциях (здесь и выше) портится входной объект изображения. Насколько я помню подобные объекты передаются по ссылке, а не по значению, т.е. портится внешний объект. Я не знаю, насколько это правильно с точки зрения использования в вашей реализации, но со стороны выглядит не очень правильным.
try: | ||
img = Image.open(img_path) | ||
except Exception: | ||
print(img_path, 'does not exist!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Логирование везде по проекту по возможности выполняется с помощью пакета logging
crop_size, | ||
resize_size, | ||
img_mean, img_std): | ||
img_path = sample[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сходу так непонятно, что такое sample. Открывая код, можно увидеть, что это неожиданно массив из двух элементов. Первый - путь до картинки, а второй я так и не поняла, что означает, поскольку не нашла, где он используется, кроме строки 135, где возвращается из этой функции. Второй элемент нужен или без него можно обойтись. Если нужен, то имеет смысл разнести на два отдельных параметра, чтобы сделать код читаемым. Если не нужен, то можно убрать из параметров.
import random | ||
import numpy as np | ||
import paddle | ||
from PIL import Image, ImageEnhance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему не используется OpenCV для базовых преобразований изображения? Просто мы везде по проекту для базовых операций обработки изображений используем OpenCV, и выглядит крайне странным использование другого пакета с аналогичным функционалом.
sample = str(self.dataset[index].absolute()) | ||
if self.mode == 'train': | ||
data, label = process_image( | ||
[sample, sample], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь и далее при таких же вызовах не поняла смысла передачи списка из друх одинаковых параметров.
@ismukhin, посмотрите, пожалуйста. |
@@ -17,6 +17,7 @@ dglgo==0.0.2 | |||
|
|||
tflite | |||
|
|||
paddleslim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше зафиксировать версию рабочую, потому что при обновлении что-то может поломаться
random.seed(0) | ||
np.random.seed(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В связи с чем фиксировался seed? Чтобы shuffle перемешивал датасет при каждом запуске одинаково? Если да, то нужно это убрать
default_crop_scale = (0.08, 1.0) | ||
default_crop_ratio = (3. / 4., 4. / 3.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не вижу, где эти переменные применяются
algo='avg', | ||
round_type='round', | ||
hist_percent=0.9999, | ||
is_full_quantize=False, | ||
bias_correction=False, | ||
onnx_format=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эти параметры варьируются в paddlepaddle
?
<Name>test</Name> | ||
<Path>../test_images/classification_images</Path> | ||
<Mean>[123.675, 116.28, 103.53]</Mean> | ||
<Std>[58.395, 57.12, 57.375]</Std> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не хватает параметра channel_swap
No description provided.