Giter VIP home page Giter VIP logo

Comments (4)

auroua avatar auroua commented on July 19, 2024

In tensorflow, element-wise assign value to tensor is not allowed. If you want to do element-wise assign you can reference the arcface_loss or cosineface_losses which contains code for assignment by using a mask.

from insightface_tf.

HsuTzuJen avatar HsuTzuJen commented on July 19, 2024

I still do not understand how to do it, So I add cutout function
"images_train = cutout(images_train, args.cutout_length)"
after
"images_train, labels_train = sess.run(next_element)"

paper : https://arxiv.org/abs/1708.04552

def cutout(images,length):
w = 112
h = 112
length = length
images = images
for k in range(len(images)):
x1 = np.random.randint(w-length)
x2 = x1 + length
y1 = np.random.randint(h-length)
y2 = y1 + length
for i in range(x1,x2):
for j in range(y1,y2):
images[k][i][j][0] = 0
images[k][i][j][1] = 0
images[k][i][j][2] = 0
return images

from insightface_tf.

auroua avatar auroua commented on July 19, 2024

images[k][i][j][0] = 0 images[k][i][j][1] = 0 images[k][i][j][2] = 0
This is not allowed in tensorflow.

  1. You should build a mask
  2. Set the element in this mask to 1
  3. Set the value of region which you want to use cutout to 0 in the mask.
  4. Do element-wise multiple between the image and the mask.

from insightface_tf.

HsuTzuJen avatar HsuTzuJen commented on July 19, 2024

Thank you for the hint.
I am still new to TF.
By the way, the data type of images_train is numpy.ndarray, so I can do with it directly.
I have tried to use the mask in the pharse_function, but the cutout regions are the same in the same batch. Could you please tell me how to fix this?

I think tf map pharse_function by batch, so each batch is matched one pharse_function operation?

from insightface_tf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.