tohinz / semantic-object-accuracy-for-generative-text-to-image-synthesis

Code for "Semantic Object Accuracy for Generative Text-to-Image Synthesis" (TPAMI 2020)
MIT License
106 stars 23 forks source link

About sampling #17

Closed gitraffica closed 3 years ago

gitraffica commented 3 years ago

I also ran into the problem here, problem and I used the corresponding code you provided:

cap = captions[0].data.cpu().numpy() sentence = "" for j in range(len(cap)): if cap[j] == 0: break word = self.ixtoword[cap[j]].encode('ascii', 'ignore').decode('ascii') sentence += word + " "

and the altered sampling function: ubuntu pastebin

I am confused about why this code was generating multiple same images under a same keys[j](referring to the screenshot below, the same generated images were sampled due to a same keys[j]), with different captions: image

gitraffica commented 3 years ago

I found out the problem by myself. The var name coincidently conflicts with the parent for loop var(.........)

cap = captions[0].data.cpu().numpy() sentence = "" for l in range(len(cap)): if cap[l] == 0: break word = self.ixtoword[cap[l]].encode('ascii', 'ignore').decode('ascii') sentence += word + " "