Installation of Slixfeed with pip fails

2024-07-30 Thread Schimon Jehudah via Python-list
Greetings, to one and all!

My name is Schimon, and I am the developer of a news chat bot for the
XMPP network, called Slixfeed.

I have recently added support for OMEMO encryption, and a friend of
mine has reported that there is an issue installing it with pip.

I suppoes this is a fault of a package at PyPi, or a fault at my
pyproject.toml.

This is the link to the project:
https://git.xmpp-it.net/sch/Slixfeed#getting-started

Please advise,
Schimon
-- 
https://mail.python.org/mailman/listinfo/python-list


Predicting an object over an pretrained model is not working

2024-07-30 Thread marc nicole via Python-list
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 added 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 = classes_name
self._num_classes = len(classes_name)

self._common_params = {'image_size': 448, 'num_classes':
self._num_classes,
'batch_size':1}
self._net_params = {'cell_size': 7, 'boxes_per_cell':2,
'weight_decay': 0.0005}
self._net = YoloTinyNet(self._common_params, self._net_params,
test=True)

def predict_object(self, image):
predicts = self._net.inference(image)
return predicts

def process_predicts(self, resized_img, predicts, thresh=0.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 = self._num_classes
bbx_per_cell = self._net_params["boxes_per_cell"]
cell_size = self._net_params["cell_size"]
img_size = self._common_params["image_size"]
p_classes = predicts[0, :, :, 0:cls_num]
C = predicts[0, :, :, cls_num:cls_num+bbx_per_cell] # two
bounding boxes in one cell.
coordinate = predicts[0, :, :, cls_num+bbx_per_cell:] # all
bounding boxes position.

p_classes = np.reshape(p_classes, (cell_size, cell_size, 1, cls_num))
C = np.reshape(C, (cell_size, cell_size, bbx_per_cell, 1))

P = C * p_classes # confidencefor all classes of all bounding
boxes (cell_size, cell_size, bounding_box_num, class_num) = (7, 7, 2,
1).

predicts_dict = {}
for i in range(cell_size):
for j in range(cell_size):
temp_data = np.zeros_like(P, np.float32)
temp_data[i, j, :, :] = P[i, j, :, :]
position = np.argmax(temp_data) # refer to the class
num (with maximum confidence) for every bounding box.
index = np.unravel_index(position, P.shape)

if P[index] > thresh:
class_num = index[-1]
coordinate = np.reshape(coordinate, (cell_size,
cell_size, bbx_per_cell, 4)) # (cell_size, cell_size,
bbox_num_per_cell, coordinate)[xmin, ymin, xmax, ymax]
max_coordinate = coordinate[index[0], index[1], index[2], :]

xcenter = max_coordinate[0]
ycenter = max_coordinate[1]
w = max_coordinate[2]
h = max_coordinate[3]

xcenter = (index[1] + xcenter) * (1.0*img_size /cell_size)
ycenter = (index[0] + ycenter) * (1.0*img_size /cell_size)

w = w * img_size
h = h * img_size
xmin = 0 if (xcenter - w/2.0 < 0) else (xcenter - w/2.0)
ymin = 0 if (xcenter - w/2.0 < 0) else (ycenter - h/2.0)
xmax = resized_img.shape[0] if (xmin + w) >
resized_img.shape[0] else (xmin + w)
ymax = resized_img.shape[1] if (ymin + h) >
resized_img.shape[1] else (ymin + h)

class_name = self._classes_name[class_num]
predicts_dict.setdefault(class_name, [])
predicts_dict[class_name].append([int(xmin),
int(ymin), int(xmax), int(ymax), P[index]])

return predicts_dict

def non_max_suppress(self, predicts_dict, threshold=0.5):
"""
implement non-maximum supression on predict bounding boxes.
Args:
predicts_dict: {"stick": [[x1, y1, x2, y2, scores1], [...]]}.
threshhold: iou threshold
Return:
predicts_dict processed by non-maximum suppression
"""
for object_name, bbox in predicts_dict.items():
bbox_array = np.array(bbox, dtype=np.float)
x1, y1, x2, y2, scores = bbox_array[:,0], bbox_array[:,1],
bbox_array[:,2], bbox_array[:,3], bbox_array[:,4]
areas = (x2-x1+1) * (y2-y1+1)
order = scores.argsort()[::-1]
keep = []
while order.size > 0:
i = order[0]
keep.append(i)
xx1 = np.maximum(x1[i], x1[order[1:]])
yy1 = np.maximum(y1[i], y1[order[1:]])
xx2 = np.minimum(x2[i], x2[order[1:]])
yy2 = np.minimum(y2[i], y2[order[1:]])
inter = np.maximum(0.0, xx2-xx1+1) * np.maximum(0.0, yy2-yy1+1)
iou = inter/(areas[i]+areas[order[1:]]

Re: Predicting an object over an pretrained model is not working

2024-07-30 Thread Thomas Passin via Python-list

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 added 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 = classes_name
 self._num_classes = len(classes_name)

 self._common_params = {'image_size': 448, 'num_classes':
self._num_classes,
 'batch_size':1}
 self._net_params = {'cell_size': 7, 'boxes_per_cell':2,
'weight_decay': 0.0005}
 self._net = YoloTinyNet(self._common_params, self._net_params,
test=True)

 def predict_object(self, image):
 predicts = self._net.inference(image)
 return predicts

 def process_predicts(self, resized_img, predicts, thresh=0.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 = self._num_classes
 bbx_per_cell = self._net_params["boxes_per_cell"]
 cell_size = self._net_params["cell_size"]
 img_size = self._common_params["image_size"]
 p_classes = predicts[0, :, :, 0:cls_num]
 C = predicts[0, :, :, cls_num:cls_num+bbx_per_cell] # two
bounding boxes in one cell.
 coordinate = predicts[0, :, :, cls_num+bbx_per_cell:] # all
bounding boxes position.

 p_classes = np.reshape(p_classes, (cell_size, cell_size, 1, cls_num))
 C = np.reshape(C, (cell_size, cell_size, bbx_per_cell, 1))

 P = C * p_classes # confidencefor all classes of all bounding
boxes (cell_size, cell_size, bounding_box_num, class_num) = (7, 7, 2,
1).

 predicts_dict = {}
 for i in range(cell_size):
 for j in range(cell_size):
 temp_data = np.zeros_like(P, np.float32)
 temp_data[i, j, :, :] = P[i, j, :, :]
 position = np.argmax(temp_data) # refer to the class
num (with maximum confidence) for every bounding box.
 index = np.unravel_index(position, P.shape)

 if P[index] > thresh:
 class_num = index[-1]
 coordinate = np.reshape(coordinate, (cell_size,
cell_size, bbx_per_cell, 4)) # (cell_size, cell_size,
bbox_num_per_cell, coordinate)[xmin, ymin, xmax, ymax]
 max_coordinate = coordinate[index[0], index[1], index[2], 
:]

 xcenter = max_coordinate[0]
 ycenter = max_coordinate[1]
 w = max_coordinate[2]
 h = max_coordinate[3]

 xcenter = (index[1] + xcenter) * (1.0*img_size /cell_size)
 ycenter = (index[0] + ycenter) * (1.0*img_size /cell_size)

 w = w * img_size
 h = h * img_size
 xmin = 0 if (xcenter - w/2.0 < 0) else (xcenter - w/2.0)
 ymin = 0 if (xcenter - w/2.0 < 0) else (ycenter - h/2.0)
 xmax = resized_img.shape[0] if (xmin + w) >
resized_img.shape[0] else (xmin + w)
 ymax = resized_img.shape[1] if (ymin + h) >
resized_img.shape[1] else (ymin + h)

 class_name = self._classes_name[class_num]
 predicts_dict.setdefault(class_name, [])
 predicts_dict[class_name].append([int(xmin),
int(ymin), int(xmax), int(ymax), P[index]])

 return predicts_dict

 def non_max_suppress(self, predicts_dict, threshold=0.5):
 """
 implement non-maximum supression on predict bounding boxes.
 Args:
 predicts_dict: {"stick": [[x1, y1, x2, y2, scores1], [...]]}.
 threshhold: iou threshold
 Return:
 predicts_dict processed by non-maximum suppression
 """
 for object_name, bbox in predicts_dict.items():
 bbox_array = np.array(bbox, dtype=np.float)
 x1, y1, x2, y2, scores = bbox_array[:,0], bbox_array[:,1],
bbox_array[:,2], bbox_array[:,3], bbox_array[:,4]
 areas = (x2-x1+1) * (y2-y1+1)
 order = scores.argsort()[::-1]
 keep = []
 while order.size > 0:
 i = order[0]
 keep.append(i)
 xx1 = np.maximum(x1[i], x1[order[1:]])
 yy1 = np.maximum(y1[i], y1[order[1:]])
 xx2 = np.minimum(x2[i], x2[order[1:]])
 yy2 = np.minimum(y2[i], y2[order[1

Re: Predicting an object over an pretrained model is not working

2024-07-30 Thread marc nicole via Python-list
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 à 21:37, Thomas Passin via Python-list <
python-list@python.org> a écrit :

> 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 added
> 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 = classes_name
> >  self._num_classes = len(classes_name)
> >
> >  self._common_params = {'image_size': 448, 'num_classes':
> > self._num_classes,
> >  'batch_size':1}
> >  self._net_params = {'cell_size': 7, 'boxes_per_cell':2,
> > 'weight_decay': 0.0005}
> >  self._net = YoloTinyNet(self._common_params, self._net_params,
> > test=True)
> >
> >  def predict_object(self, image):
> >  predicts = self._net.inference(image)
> >  return predicts
> >
> >  def process_predicts(self, resized_img, predicts, thresh=0.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 = self._num_classes
> >  bbx_per_cell = self._net_params["boxes_per_cell"]
> >  cell_size = self._net_params["cell_size"]
> >  img_size = self._common_params["image_size"]
> >  p_classes = predicts[0, :, :, 0:cls_num]
> >  C = predicts[0, :, :, cls_num:cls_num+bbx_per_cell] # two
> > bounding boxes in one cell.
> >  coordinate = predicts[0, :, :, cls_num+bbx_per_cell:] # all
> > bounding boxes position.
> >
> >  p_classes = np.reshape(p_classes, (cell_size, cell_size, 1,
> cls_num))
> >  C = np.reshape(C, (cell_size, cell_size, bbx_per_cell, 1))
> >
> >  P = C * p_classes # confidencefor all classes of all bounding
> > boxes (cell_size, cell_size, bounding_box_num, class_num) = (7, 7, 2,
> > 1).
> >
> >  predicts_dict = {}
> >  for i in range(cell_size):
> >  for j in range(cell_size):
> >  temp_data = np.zeros_like(P, np.float32)
> >  temp_data[i, j, :, :] = P[i, j, :, :]
> >  position = np.argmax(temp_data) # refer to the class
> > num (with maximum confidence) for every bounding box.
> >  index = np.unravel_index(position, P.shape)
> >
> >  if P[index] > thresh:
> >  class_num = index[-1]
> >  coordinate = np.reshape(coordinate, (cell_size,
> > cell_size, bbx_per_cell, 4)) # (cell_size, cell_size,
> > bbox_num_per_cell, coordinate)[xmin, ymin, xmax, ymax]
> >  max_coordinate = coordinate[index[0], index[1],
> index[2], :]
> >
> >  xcenter = max_coordinate[0]
> >  ycenter = max_coordinate[1]
> >  w = max_coordinate[2]
> >  h = max_coordinate[3]
> >
> >  xcenter = (index[1] + xcenter) * (1.0*img_size
> /cell_size)
> >  ycenter = (index[0] + ycenter) * (1.0*img_size
> /cell_size)
> >
> >  w = w * img_size
> >  h = h * img_size
> >  xmin = 0 if (xcenter - w/2.0 < 0) else (xcenter -
> w/2.0)
> >  ymin = 0 if (xcenter - w/2.0 < 0) else (ycenter -
> h/2.0)
> >  xmax = resized_img.shape[0] if (xmin + w) >
> > resized_img.shape[0] else (xmin + w)
> >  ymax = resized_img.shape[1] if (ymin + h) >
> > resized_img.shape[1] else (ymin + h)
> >
> >  class_name = self._classes_name[class_num]
> >  predicts_dict.setdefault(class_name, [])
> >  predicts_dict[class_name].append([int(xmin),
> > int(ymin), int(xmax), int(ymax), P[index]])
> >
> >  return predicts_dict
> >
> >  def non_max_suppress(self, predicts_dict, threshold=0.5):
> >  """
> >  implement non-maximum supression on predict bounding boxes.
> >  Args:
> >  predicts_dict: {"stick": [[x1, y1, x2, y2, scores1],
> [...]]}.
> >  threshhold: iou threshold
> >  Return:
> >  predicts_dict processed by non-maximum suppression
> >  """
> >  f

Re: Predicting an object over an pretrained model is not working

2024-07-30 Thread Thomas Passin via Python-list

On 7/30/2024 4:49 PM, marc nicole wrote:
OK, but how's the probability of small_ball greater than others? I can't 
find it anyway, what's its value?


It's your code. I wouldn't know. I suppose it's represented somewhere in 
all those parameters. You need to understand what those function calls 
are returning.  It's documented somewhere, right?


And you really do need to know the probabilities of the competing images 
because otherwise you won't know how confident you can be that the 
identification is a strong one.


Le mar. 30 juil. 2024 à 21:37, Thomas Passin via Python-list 
mailto:python-list@python.org>> a écrit :


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 added 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 = classes_name
 >          self._num_classes = len(classes_name)
 >
 >          self._common_params = {'image_size': 448, 'num_classes':
 > self._num_classes,
 >                  'batch_size':1}
 >          self._net_params = {'cell_size': 7, 'boxes_per_cell':2,
 > 'weight_decay': 0.0005}
 >          self._net = YoloTinyNet(self._common_params,
self._net_params,
 > test=True)
 >
 >      def predict_object(self, image):
 >          predicts = self._net.inference(image)
 >          return predicts
 >
 >      def process_predicts(self, resized_img, predicts, thresh=0.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 = self._num_classes
 >          bbx_per_cell = self._net_params["boxes_per_cell"]
 >          cell_size = self._net_params["cell_size"]
 >          img_size = self._common_params["image_size"]
 >          p_classes = predicts[0, :, :, 0:cls_num]
 >          C = predicts[0, :, :, cls_num:cls_num+bbx_per_cell] # two
 > bounding boxes in one cell.
 >          coordinate = predicts[0, :, :, cls_num+bbx_per_cell:] # all
 > bounding boxes position.
 >
 >          p_classes = np.reshape(p_classes, (cell_size, cell_size,
1, cls_num))
 >          C = np.reshape(C, (cell_size, cell_size, bbx_per_cell, 1))
 >
 >          P = C * p_classes # confidencefor all classes of all
bounding
 > boxes (cell_size, cell_size, bounding_box_num, class_num) = (7, 7, 2,
 > 1).
 >
 >          predicts_dict = {}
 >          for i in range(cell_size):
 >              for j in range(cell_size):
 >                  temp_data = np.zeros_like(P, np.float32)
 >                  temp_data[i, j, :, :] = P[i, j, :, :]
 >                  position = np.argmax(temp_data) # refer to the class
 > num (with maximum confidence) for every bounding box.
 >                  index = np.unravel_index(position, P.shape)
 >
 >                  if P[index] > thresh:
 >                      class_num = index[-1]
 >                      coordinate = np.reshape(coordinate, (cell_size,
 > cell_size, bbx_per_cell, 4)) # (cell_size, cell_size,
 > bbox_num_per_cell, coordinate)[xmin, ymin, xmax, ymax]
 >                      max_coordinate = coordinate[index[0],
index[1], index[2], :]
 >
 >                      xcenter = max_coordinate[0]
 >                      ycenter = max_coordinate[1]
 >                      w = max_coordinate[2]
 >                      h = max_coordinate[3]
 >
 >                      xcenter = (index[1] + xcenter) *
(1.0*img_size /cell_size)
 >                      ycenter = (index[0] + ycenter) *
(1.0*img_size /cell_size)
 >
 >                      w = w * img_size
 >                      h = h * img_size
 >                      xmin = 0 if (xcenter - w/2.0 < 0) else
(xcenter - w/2.0)
 >                      ymin = 0 if (xcenter - w/2.0 < 0) else
(ycenter - h/2.0)
 >                      xmax = resized_img.shape[0] if (xmin + w) >
 > resized_img.shape[0] else (xmin + w)
 >                      ymax = resized_img.shape[1] if (ymin + h) >
 > resized_img

Re: Predicting an object over an pretrained model is not working

2024-07-30 Thread dn via Python-list

On 31/07/24 06:18, 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 added 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:


...



WHile I expect only the dict to contain the small_ball key



How's that is possible? where's the prediction output?How to fix the code?



To save us lots of reading and study to be able to help you, please advise:

1 what are the meanings of all these numbers?


'sheep': [[233.0, 92.0, 448.0, -103.0,

5.3531270027160645], [167.0, 509.0, 209.0, 101.0, 4.947688579559326],
[0.0, 0.0, 448.0, 431.0, 3.393721580505371]]


2 (assuming it hasn't) why the dict has not been sorted into a 
meaningful order


3 how can one tell that the image is more likely to be a sheep than a train?

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list