Deutsch   English   Français   Italiano  
<mailman.49.1722372595.2981.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: marc nicole <mk1853387@gmail.com>
Newsgroups: comp.lang.python
Subject: Re: Predicting an object over an pretrained model is not working
Date: Tue, 30 Jul 2024 22:49:21 +0200
Lines: 269
Message-ID: <mailman.49.1722372595.2981.python-list@python.org>
References: <CAGJtH9Qjv2fQm=_HKwhoGS11uh+u4YoTVzYGHF=2jZC9HpdV9A@mail.gmail.com>
 <263356ef-7ad8-4abc-9940-bd8536ee13eb@tompassin.net>
 <CAGJtH9TnoFa_JJNi=E0oDouKZjq_sfGYmr0WOFOfZtaGcQTyXA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de FfrqhfRW+I/b+9pFhU271Q268NLyUeoCLFZ87KYbtpVg==
Cancel-Lock: sha1:0+luE/LnbzDo9LGWEmO9KljyGNE= sha256:8rwBoI9ZfcYKPq3IGICKRJSfzFB7va5EaRxvJOSV/bU=
Return-Path: <mk1853387@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
 reason="2048-bit key; unprotected key"
 header.d=gmail.com header.i=@gmail.com header.b=FyFfa/fV;
 dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'knows': 0.04;
 'image.': 0.07; '"""': 0.09; 'anyway,': 0.09; 'cell.': 0.09;
 'code?': 0.09; 'compute': 0.09; 'coordinate': 0.09; 'email
 addr:python.org>': 0.09; 'ok,': 0.09; 'output:': 0.09; 'skip:[
 20': 0.09; 'skip:x 10': 0.09; 'skip:\xc2 20': 0.09; 'subject:not':
 0.09; 'tensorflow': 0.09; 'threshold': 0.09; '>': 0.14;
 'url:mailman': 0.15; '<': 0.16; '(1,': 0.16; '2024': 0.16;
 '=\xc2\xa0': 0.16; 'annotated': 0.16; 'args:': 0.16; 'box.': 0.16;
 'dict': 0.16; 'input.': 0.16; 'possible?': 0.16; 'predicts': 0.16;
 'skip:5 20': 0.16; 'subject:model': 0.16; 'subject:working': 0.16;
 'value?': 0.16; 'wrote:': 0.16; 'problem': 0.16; "can't": 0.17;
 'figure': 0.19; 'implement': 0.19; 'pm,': 0.19; 'to:addr:python-
 list': 0.20; 'all,': 0.20; 'input': 0.21; 'skip:& 40': 0.22;
 'skip:_ 10': 0.22; "what's": 0.22; 'code': 0.23; 'skip:p 30':
 0.23; 'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24':
 0.25; 'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'classes':
 0.26; 'object': 0.26; 'else': 0.27; 'expect': 0.28; 'output':
 0.28; 'email addr:python.org>': 0.28; 'code,': 0.31; 'url-
 ip:188/8': 0.31; 'objects': 0.32; 'python-list': 0.32; 'message-
 id:@mail.gmail.com': 0.32; 'skip:2 10': 0.32; 'but': 0.32; 'able':
 0.34; 'skip:" 20': 0.34; 'header:In-Reply-To:1': 0.34;
 'received:google.com': 0.34; 'trying': 0.35; 'skip:2 20': 0.35;
 'following': 0.35; 'from:addr:gmail.com': 0.35; 'fix': 0.36;
 'target': 0.36; 'source': 0.36; "skip:' 10": 0.37; 'using': 0.37;
 'class': 0.37; 'two': 0.39; 'added': 0.39; 'single': 0.39;
 '(with': 0.39; 'processed': 0.40; 'skip:( 30': 0.40; 'want': 0.40;
 'skip:0 20': 0.61; 'skip:o 10': 0.61; 'skip:\xc2 10': 0.62;
 'subject': 0.63; 'skip:m 20': 0.63; 'skip:b 10': 0.63; 'skip:k
 10': 0.64; 'key': 0.64; 'skip:r 20': 0.64; 'probability': 0.64;
 'box': 0.65; 'skip:t 20': 0.66; 'skip:1 20': 0.67; 'skip:n 30':
 0.67; 'areas': 0.67; 'maximum': 0.67; 'order': 0.69; 'model.':
 0.69; 'prediction': 0.69; 'skip:y 30': 0.69; 'skip:4 10': 0.75;
 'skip:y 10': 0.76; 'detection': 0.76; 'database': 0.80;
 'position': 0.81; '",': 0.84; 'email name:<python-list':
 0.84; 'mar.': 0.84; 'subject:over': 0.84; '\xc3\xa9crit\xc2\xa0:':
 0.84; 'greater': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1722372592; x=1722977392; darn=python.org;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :from:to:cc:subject:date:message-id:reply-to;
 bh=JWWZOJFWBmsSoz36Vd70oRIWcdxNL9SFv8Z69NjJ6rs=;
 b=FyFfa/fVaFNgPi+GM8+AvhOvdtKlFioeJC3oqzp/h6ZNyYu6SZayRIHK9GF+dPffw4
 QQwv+tDuX4Zjtwl3a04oqmm1Pxx4sMdCstjsyZZmlsGlpwiF6pr1wMWjy18gi53sFMMA
 q3o32+qd6QDIh+0JeEV84+DgTTFkjbOAU236Uh0xk3qrfy+UdVUnQvnhqie69Ex7sY18
 lpnyRqfrH6N/MthEL6lYTAMua8q6IE7QHOlsZXt4w2v32S4a0/bbQxZyzyNj1gXOw/um
 e0Oa6wPJKv1aj5N9UierNxBAnw3MRCS1ebUtb19X2uvvepKtgXwkk0bGhhxxmnud+5cn
 mO7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1722372592; x=1722977392;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=JWWZOJFWBmsSoz36Vd70oRIWcdxNL9SFv8Z69NjJ6rs=;
 b=t9MhEwL3eqQ03QhMeFzXpBD0wj0bplzr16/QUpHi8ZkUuHn4hz4XN+tu0WaN+PONzX
 4XFJoHht31AKtqhc09H7sAMPqAwc+1tykc+hTFlRFpEnFsGUcYiSyfsiM1G6PIePZwco
 xYSKtmVHJ0Daji/qoS3VAHqPqbyI5oi3LvD96WP0TBGpiwK5qlYStZcaCM5hpVMqPR2A
 jsTkEsHN/PucEQs/1STVd0hcLk6g1pu2FMCpYFDu2nizFaJUE58KuPs1M02Gp2bm3pa6
 RcEJ6AupVoO/hk2L8M95gF7Gz9YOY8lN0lstnE60LXH3FnBkqiR5HfsuL5xJBz6mmJBu
 OIOA==
X-Forwarded-Encrypted: i=1;
 AJvYcCUHUulD1B5fXz1EZ8XVDR1v4iSsTgrKDSDFVTgzFlNwnPdM94WRUSc/W/xd3CjYkndDeElGPEFuJO62uw==@python.org
X-Gm-Message-State: AOJu0YxpyknIPCxo037+RlLjTn0A4s10RBrt6lt04Ub28uHK4FZz7Gwz
 EiwOkX27cNYGw6GGQXBYOU7f08js3uDHFD+9HnyKi6zlGV0vxFRaXCSH9CNhC/TiiE9PV0q3GXC
 2+4ZvxE9tIS9uB8IzBmT02GPTmMCArlg5
X-Google-Smtp-Source: AGHT+IGVWgKUY52/Gqw4re04ZsWrm9IT6NYAvO+KKgx0xo2IiT1gnxniSrc7XEnoGOVHJx4pIvixLsOay8/hoeuwvlk=
X-Received: by 2002:a0d:f8c3:0:b0:631:43e1:6b99 with SMTP id
 00721157ae682-67a06727c1emr147529747b3.12.1722372591739; Tue, 30 Jul 2024
 13:49:51 -0700 (PDT)
In-Reply-To: <263356ef-7ad8-4abc-9940-bd8536ee13eb@tompassin.net>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
 <python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
 <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
 <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAGJtH9TnoFa_JJNi=E0oDouKZjq_sfGYmr0WOFOfZtaGcQTyXA@mail.gmail.com>
X-Mailman-Original-References: <CAGJtH9Qjv2fQm=_HKwhoGS11uh+u4YoTVzYGHF=2jZC9HpdV9A@mail.gmail.com>
 <263356ef-7ad8-4abc-9940-bd8536ee13eb@tompassin.net>
Bytes: 17802

OK, but how's the probability of small_ball greater than others? I can't
find it anyway, what's its value?

Le mar. 30 juil. 2024 =C3=A0 21:37, Thomas Passin via Python-list <
python-list@python.org> a =C3=A9crit :

> On 7/30/2024 2:18 PM, marc nicole via Python-list wrote:
> > Hello all,
> >
> > I want to predict an object by given as input an image and want to have
> my
> > model be able to predict the label. I have trained a model using
> tensorflow
> > based on annotated database where the target object to predict was adde=
d
> to
> > the pretrained model. the code I am using is the following where I set
> the
> > target object image as input and want to have the prediction output:
> >
> >
> >
> >
> >
> >
> >
> >
> > class MultiObjectDetection():
> >
> >      def __init__(self, classes_name):
> >
> >          self._classes_name =3D classes_name
> >          self._num_classes =3D len(classes_name)
> >
> >          self._common_params =3D {'image_size': 448, 'num_classes':
> > self._num_classes,
> >                  'batch_size':1}
> >          self._net_params =3D {'cell_size': 7, 'boxes_per_cell':2,
> > 'weight_decay': 0.0005}
> >          self._net =3D YoloTinyNet(self._common_params, self._net_param=
s,
> > test=3DTrue)
> >
> >      def predict_object(self, image):
> >          predicts =3D self._net.inference(image)
> >          return predicts
> >
> >      def process_predicts(self, resized_img, predicts, thresh=3D0.2):
> >          """
> >          process the predicts of object detection with one image input.
> >
> >          Args:
> >              resized_img: resized source image.
> >              predicts: output of the model.
> >              thresh: thresh of bounding box confidence.
> >          Return:
> >              predicts_dict: {"stick": [[x1, y1, x2, y2, scores1],
> [...]]}.
> >          """
> >          cls_num =3D self._num_classes
> >          bbx_per_cell =3D self._net_params["boxes_per_cell"]
> >          cell_size =3D self._net_params["cell_size"]
> >          img_size =3D self._common_params["image_size"]
> >          p_classes =3D predicts[0, :, :, 0:cls_num]
> >          C =3D predicts[0, :, :, cls_num:cls_num+bbx_per_cell] # two
> > bounding boxes in one cell.
> >          coordinate =3D predicts[0, :, :, cls_num+bbx_per_cell:] # all
> > bounding boxes position.
> >
> >          p_classes =3D np.reshape(p_classes, (cell_size, cell_size, 1,
> cls_num))
> >          C =3D np.reshape(C, (cell_size, cell_size, bbx_per_cell, 1))
> >
> >          P =3D C * p_classes # confidencefor all classes of all boundin=
g
> > boxes (cell_size, cell_size, bounding_box_num, class_num) =3D (7, 7, 2,
> > 1).
> >
> >          predicts_dict =3D {}
> >          for i in range(cell_size):
> >              for j in range(cell_size):
> >                  temp_data =3D np.zeros_like(P, np.float32)
> >                  temp_data[i, j, :, :] =3D P[i, j, :, :]
> >                  position =3D np.argmax(temp_data) # refer to the class
> > num (with maximum confidence) for every bounding box.
> >                  index =3D np.unravel_index(position, P.shape)
> >
> >                  if P[index] > thresh:
> >                      class_num =3D index[-1]
> >                      coordinate =3D np.reshape(coordinate, (cell_size,
> > cell_size, bbx_per_cell, 4)) # (cell_size, cell_size,
========== REMAINDER OF ARTICLE TRUNCATED ==========