train_ssd_mobilenet icon indicating copy to clipboard operation
train_ssd_mobilenet copied to clipboard

Training with background images

Open PiyalGeorge opened this issue 4 years ago • 5 comments

Hi @naisy ,

I have trained a model in mobilenet-ssd-v2 model in Tensorflow(less than version 2.0) for detecting "mobile-phone in hand". I trained with images having 'mobile-phones in hand'. Threshold is set to 7. So if hold a mobile-phone in my hand it will detect. This scenario is working, but the issue is when i hold some other objects(like cup, pen) in my hand, that also is getting detected. That is, i'm getting wrong detection. How can i reduce this wrong detection? Will training with other images like - image having hand held cup, book, etc without specifying label in xml - help to avoid these wrong detection?

I have gone through some issues in github regarding this, but still i'm not getting a clarity on this, that's why i come to you. Hope you will help me to get a clarity on this. Kindly help me.

PiyalGeorge avatar Jun 25 '20 08:06 PiyalGeorge

Hi @PiyalGeorge,

Prepare images with the phone in one hand and the cup in the other. In other words, add in the training data what you do not want to recognize. (as background label. if you don't make label, that area goes background label.) This trick is very important for good results.

naisy avatar Jun 25 '20 09:06 naisy

Thanks for the reply, @naisy . One more doubt on same topic- This is how my annotation for an image with mobile-in-hand looks like:

<annotation>
	<folder>cropped</folder>
	<filename>2.jpg</filename>
	<path>/home/2.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>500</width>
		<height>500</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>mobileinhand</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>247</xmin>
			<ymin>266</ymin>
			<xmax>296</xmax>
			<ymax>304</ymax>
		</bndbox>
	</object>
</annotation>

So, Can i include new images for 'learning background only' (eg: images having cup-in-hand kinda) with xml like below(With no object specified in xml), Is this method possible:

<annotation>
	<folder>cropped</folder>
	<filename>2.jpg</filename>
	<path>/home/2.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>500</width>
		<height>500</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
</annotation>

PiyalGeorge avatar Jun 25 '20 10:06 PiyalGeorge

Hi @PiyalGeorge,

Background only is possible, but be careful. Such data increases accuracy when predict everything as background. If too much, the weight balance tends to bad.

naisy avatar Jun 25 '20 10:06 naisy

@naisy Thanks alot :balloon: :balloon: :candy:

PiyalGeorge avatar Jun 25 '20 10:06 PiyalGeorge

@PiyalGeorge I hope you find it useful.

naisy avatar Jun 25 '20 10:06 naisy