alexhex7 / simgan_pytorch Goto Github PK
View Code? Open in Web Editor NEW[Refer to wayaai/SimGAN(Keras&Tensorflow)] Implementation of Apple's Learning from Simulated and Unsupervised Images through Adversarial Training
[Refer to wayaai/SimGAN(Keras&Tensorflow)] Implementation of Apple's Learning from Simulated and Unsupervised Images through Adversarial Training
Hi @AlexHex7
I am interested in your implementation. But I am also interested if you achived new results from the shown on the Github page? Did you achieve the same results as from the paper?
https://github.com/AlexHex7/SimGAN_pytorch/blob/654099b7428c4c75ee4e242a1611f580f5d5e4f9/main.py#L197
Shouldn't it be acc_adv = calc_acc(d_ref_pred, 'refine')
instead?
I did some training using this repo and the results are not very satisfactory. After a closer look at the code I found a bug in the ImageHistoryBuffer implementation :
np.append(self.image_history_buffer, images[:nb_to_add], axis=0)
Per np.append
Returns
appendndarray
A copy of arr with values appended to axis. Note that append does not occur in-place: a new array is allocated and filled. If axis is None, out is a flattened array.
The function call itself won't modify the source array and the image buffer will never be filled with anything. This can be verified by printing the buffer size during training.
Here's a fix and modification for better efficiency (list.extend is done in-place to avoid copying the entire image buffer).
class ImageHistoryBuffer(object):
def __init__(self, max_size, batch_size):
self.image_history_buffer = []
self.max_size = max_size
self.batch_size = batch_size
def add_to_buffer(self, images, num_to_add=None):
if not num_to_add:
num_to_add = self.batch_size // 2
images = images.tolist()
if len(self.image_history_buffer) < self.max_size:
num_to_add = min(num_to_add, self.max_size - len(self.image_history_buffer))
self.image_history_buffer.extend(images[:num_to_add])
elif len(self.image_history_buffer) == self.max_size:
self.image_history_buffer[:num_to_add] = images[:num_to_add]
else:
assert False, "Image history buffer overflow"
random.shuffle(self.image_history_buffer)
def get_from_buffer(self, num_to_get=None):
if not num_to_get:
num_to_get = self.batch_size // 2
try:
return np.array(self.image_history_buffer[:num_to_get], dtype=np.float32)
except IndexError:
return np.zeros(shape=0)
Hope this helps!
Hi, AlexHex7.
I forked your code and did several changes for bug fixing and speed-up.
But my training procedure wasn't pleasant. I tested many hyper-parameters but the results were still terrible. Could you share your training log with me? Thanks a lot.
You put an assert statement to check , if size of real images and synthetic images are matching
for pre training Discriminator , but the sizes are different
128 != 52 , because of this it is throwing an error.
Why is that necessary ? How do I fix the error ? Am I working with wrong dataset ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.