Skip to content

Квантизация 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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

IgorKonovalovAleks
Copy link
Contributor

No description provided.

@IgorKonovalovAleks IgorKonovalovAleks marked this pull request as draft March 27, 2025 21:13
@IgorKonovalovAleks IgorKonovalovAleks marked this pull request as ready for review April 11, 2025 05:59
@IgorKonovalovAleks IgorKonovalovAleks marked this pull request as draft April 11, 2025 06:58
THREAD = 16
BUF_SIZE = 10240

DATA_DIR = r'D:\ws\dl-benchmark\imagenet'
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком много всего в одном скрипте. Предлагаю разделить хотя бы на два: 1 - то, что имеет отношение непосредственно к обработке изображений, 2 - то, что имеет отношение к загрузке данных и последующей обработке с использование 1.

@@ -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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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!')
Copy link
Contributor

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]
Copy link
Contributor

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
Copy link
Contributor

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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь и далее при таких же вызовах не поняла смысла передачи списка из друх одинаковых параметров.

@IgorKonovalovAleks IgorKonovalovAleks marked this pull request as ready for review April 25, 2025 06:33
@valentina-kustikova
Copy link
Contributor

@ismukhin, посмотрите, пожалуйста.

@@ -17,6 +17,7 @@ dglgo==0.0.2

tflite

paddleslim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше зафиксировать версию рабочую, потому что при обновлении что-то может поломаться

Comment on lines +14 to +15
random.seed(0)
np.random.seed(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В связи с чем фиксировался seed? Чтобы shuffle перемешивал датасет при каждом запуске одинаково? Если да, то нужно это убрать

Comment on lines +17 to +18
default_crop_scale = (0.08, 1.0)
default_crop_ratio = (3. / 4., 4. / 3.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не вижу, где эти переменные применяются

Comment on lines +96 to +101
algo='avg',
round_type='round',
hist_percent=0.9999,
is_full_quantize=False,
bias_correction=False,
onnx_format=False)
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не хватает параметра channel_swap

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

Successfully merging this pull request may close these issues.

3 participants