AttributeError: 'NoneType' object has no attribute 'shape' In Google Colab demo #336

Open
opened 2022-10-28 17:53:01 +02:00 by Pokeman11 · 1 comment
Pokeman11 commented 2022-10-28 17:53:01 +02:00 (Migrated from github.com)

------------ Options -------------
Arc_path: models/BEST_checkpoint.tar
aspect_ratio: 1.0
batchSize: 8
checkpoints_dir: ./checkpoints
cluster_path: features_clustered_010.npy
crop_size: 224
data_type: 32
dataroot: ./datasets/cityscapes/
display_winsize: 512
engine: None
export_onnx: None
f: /root/.local/share/jupyter/runtime/kernel-c658d45c-eca0-4802-ae1e-33ceab63846b.json
feat_num: 3
fineSize: 512
fp16: False
gpu_ids: [0]
how_many: 50
id_thres: 0.03
image_size: 224
input_nc: 3
instance_feat: False
isTrain: False
label_feat: False
label_nc: 0
latent_size: 512
loadSize: 1024
load_features: False
local_rank: 0
max_dataset_size: inf
model: pix2pixHD
multisepcific_dir: ./demo_file/multispecific
nThreads: 2
n_blocks_global: 6
n_blocks_local: 3
n_clusters: 10
n_downsample_E: 4
n_downsample_global: 3
n_local_enhancers: 1
name: people
nef: 16
netG: global
ngf: 64
niter_fix_global: 0
no_flip: False
no_instance: False
no_simswaplogo: False
norm: batch
norm_G: spectralspadesyncbatch3x3
ntest: inf
onnx: None
output_nc: 3
output_path: ./output/
phase: test
pic_a_path: ./crop_224/gdg.jpg
pic_b_path: ./crop_224/zrf.jpg
pic_specific_path: ./crop_224/zrf.jpg
resize_or_crop: scale_width
results_dir: ./results/
semantic_nc: 3
serial_batches: False
temp_path: ./temp_results
tf_log: False
use_dropout: False
use_encoded_image: False
use_mask: False
verbose: False
video_path: ./demo_file/multi_people_1080p.mp4
which_epoch: latest
-------------- End ----------------
input mean and std: 127.5 127.5
find model: ./insightface_func/models/antelope/glintr100.onnx recognition
find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection
set det-size: (640, 640)

AttributeError Traceback (most recent call last)
in
24 # img_a = Image.open(pic_a).convert('RGB')
25 img_a_whole = cv2.imread(pic_a)
---> 26 img_a_align_crop, _ = app.get(img_a_whole,crop_size)
27 img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB))
28 img_a = transformer_Arcface(img_a_align_crop_pil)

1 frames
/usr/local/lib/python3.7/dist-packages/insightface/model_zoo/scrfd.py in detect(self, img, threshold, input_size, max_num, metric)
202 input_size = self.input_size if input_size is None else input_size
203
--> 204 im_ratio = float(img.shape[0]) / img.shape[1]
205 model_ratio = float(input_size[1]) / input_size[0]
206 if im_ratio>model_ratio:

AttributeError: 'NoneType' object has no attribute 'shape'

------------ Options ------------- Arc_path: models/BEST_checkpoint.tar aspect_ratio: 1.0 batchSize: 8 checkpoints_dir: ./checkpoints cluster_path: features_clustered_010.npy crop_size: 224 data_type: 32 dataroot: ./datasets/cityscapes/ display_winsize: 512 engine: None export_onnx: None f: /root/.local/share/jupyter/runtime/kernel-c658d45c-eca0-4802-ae1e-33ceab63846b.json feat_num: 3 fineSize: 512 fp16: False gpu_ids: [0] how_many: 50 id_thres: 0.03 image_size: 224 input_nc: 3 instance_feat: False isTrain: False label_feat: False label_nc: 0 latent_size: 512 loadSize: 1024 load_features: False local_rank: 0 max_dataset_size: inf model: pix2pixHD multisepcific_dir: ./demo_file/multispecific nThreads: 2 n_blocks_global: 6 n_blocks_local: 3 n_clusters: 10 n_downsample_E: 4 n_downsample_global: 3 n_local_enhancers: 1 name: people nef: 16 netG: global ngf: 64 niter_fix_global: 0 no_flip: False no_instance: False no_simswaplogo: False norm: batch norm_G: spectralspadesyncbatch3x3 ntest: inf onnx: None output_nc: 3 output_path: ./output/ phase: test pic_a_path: ./crop_224/gdg.jpg pic_b_path: ./crop_224/zrf.jpg pic_specific_path: ./crop_224/zrf.jpg resize_or_crop: scale_width results_dir: ./results/ semantic_nc: 3 serial_batches: False temp_path: ./temp_results tf_log: False use_dropout: False use_encoded_image: False use_mask: False verbose: False video_path: ./demo_file/multi_people_1080p.mp4 which_epoch: latest -------------- End ---------------- input mean and std: 127.5 127.5 find model: ./insightface_func/models/antelope/glintr100.onnx recognition find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection set det-size: (640, 640) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) [<ipython-input-42-1adc43f69880>](https://vduko7pzmcf-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20221026-060043-RC00_483928510#) in <module> 24 # img_a = Image.open(pic_a).convert('RGB') 25 img_a_whole = cv2.imread(pic_a) ---> 26 img_a_align_crop, _ = app.get(img_a_whole,crop_size) 27 img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) 28 img_a = transformer_Arcface(img_a_align_crop_pil) 1 frames [/usr/local/lib/python3.7/dist-packages/insightface/model_zoo/scrfd.py](https://vduko7pzmcf-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20221026-060043-RC00_483928510#) in detect(self, img, threshold, input_size, max_num, metric) 202 input_size = self.input_size if input_size is None else input_size 203 --> 204 im_ratio = float(img.shape[0]) / img.shape[1] 205 model_ratio = float(input_size[1]) / input_size[0] 206 if im_ratio>model_ratio: AttributeError: 'NoneType' object has no attribute 'shape'
ariraz513 commented 2023-05-05 22:29:50 +02:00 (Migrated from github.com)

was playing around and found a few things that helped:
1.there is a box with pip install commands that if you run and get a red error about imageio 2.4.1 being incompatible change it to 2.28.1
2. Lower the treshhold of detection as mentioned here #39 , had to lower mine to 0.2 in order for this to work, just play around with it.
3. I don't know if it is a must but it did help me: t try uploading a square that is 512x512 as the face and it has to have a background, not transparent.

was playing around and found a few things that helped: 1.there is a box with pip install commands that if you run and get a red error about imageio 2.4.1 being incompatible change it to 2.28.1 2. Lower the treshhold of detection as mentioned here #39 , had to lower mine to 0.2 in order for this to work, just play around with it. 3. I don't know if it is a must but it did help me: t try uploading a square that is 512x512 as the face and it has to have a background, not transparent.
Sign in to join this conversation.