Search code examples
machine-learningcomputer-visionimage-recognitionimageailabelimg

How should I box multiple same objects in the same image


I am using labelImg to create .xml files for training images. While training photos, I've come across a photo containing more than one of the same objects in the same photo.

For example, the photo below contains tens of swimmers in the same photo. Now, when I train custom objects for object recognition task, I create one .xml file for corresponding .jpg file. But here, I will end up with many .xml files from the same photo. So, I don't know what to do here.

Please help.

Multiple same objects


Solution

  • labelIMG allows you to create an xml file with multiple boxes of the same class, just save it as PascalVOC format:

    enter image description here

    Result:

    <annotation>
        <folder>img</folder>
        <filename>Pcf5D.png</filename>
        <path>/home/Desktop/img/Pcf5D.png</path>
        <source>
            <database>Unknown</database>
        </source>
        <size>
            <width>527</width>
            <height>393</height>
            <depth>3</depth>
        </size>
        <segmented>0</segmented>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>64</xmin>
                <ymin>270</ymin>
                <xmax>105</xmax>
                <ymax>310</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>87</xmin>
                <ymin>123</ymin>
                <xmax>114</xmax>
                <ymax>145</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>90</xmin>
                <ymin>144</ymin>
                <xmax>116</xmax>
                <ymax>168</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>127</xmin>
                <ymin>119</ymin>
                <xmax>146</xmax>
                <ymax>162</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>166</xmin>
                <ymin>164</ymin>
                <xmax>183</xmax>
                <ymax>202</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>119</xmin>
                <ymin>201</ymin>
                <xmax>138</xmax>
                <ymax>238</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>146</xmin>
                <ymin>225</ymin>
                <xmax>156</xmax>
                <ymax>259</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>180</xmin>
                <ymin>246</ymin>
                <xmax>197</xmax>
                <ymax>286</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>18</xmin>
                <ymin>364</ymin>
                <xmax>43</xmax>
                <ymax>391</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>164</xmin>
                <ymin>353</ymin>
                <xmax>181</xmax>
                <ymax>392</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>184</xmin>
                <ymin>353</ymin>
                <xmax>199</xmax>
                <ymax>389</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>216</xmin>
                <ymin>276</ymin>
                <xmax>242</xmax>
                <ymax>300</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>235</xmin>
                <ymin>301</ymin>
                <xmax>251</xmax>
                <ymax>331</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>250</xmin>
                <ymin>261</ymin>
                <xmax>270</xmax>
                <ymax>301</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>270</xmin>
                <ymin>261</ymin>
                <xmax>288</xmax>
                <ymax>300</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>292</xmin>
                <ymin>259</ymin>
                <xmax>307</xmax>
                <ymax>302</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>266</xmin>
                <ymin>211</ymin>
                <xmax>287</xmax>
                <ymax>252</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>273</xmin>
                <ymin>133</ymin>
                <xmax>293</xmax>
                <ymax>163</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>149</xmin>
                <ymin>150</ymin>
                <xmax>160</xmax>
                <ymax>184</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>129</xmin>
                <ymin>83</ymin>
                <xmax>142</xmax>
                <ymax>119</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>101</xmin>
                <ymin>51</ymin>
                <xmax>123</xmax>
                <ymax>91</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>116</xmin>
                <ymin>17</ymin>
                <xmax>132</xmax>
                <ymax>53</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>134</xmin>
                <ymin>8</ymin>
                <xmax>151</xmax>
                <ymax>56</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>151</xmin>
                <ymin>9</ymin>
                <xmax>172</xmax>
                <ymax>56</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>155</xmin>
                <ymin>56</ymin>
                <xmax>175</xmax>
                <ymax>93</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>142</xmin>
                <ymin>81</ymin>
                <xmax>158</xmax>
                <ymax>114</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>185</xmin>
                <ymin>45</ymin>
                <xmax>198</xmax>
                <ymax>90</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>216</xmin>
                <ymin>37</ymin>
                <xmax>239</xmax>
                <ymax>72</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>154</xmin>
                <ymin>243</ymin>
                <xmax>168</xmax>
                <ymax>273</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>166</xmin>
                <ymin>261</ymin>
                <xmax>180</xmax>
                <ymax>275</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>298</xmin>
                <ymin>223</ymin>
                <xmax>316</xmax>
                <ymax>259</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>311</xmin>
                <ymin>189</ymin>
                <xmax>328</xmax>
                <ymax>219</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>306</xmin>
                <ymin>148</ymin>
                <xmax>323</xmax>
                <ymax>183</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>317</xmin>
                <ymin>115</ymin>
                <xmax>336</xmax>
                <ymax>150</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>354</xmin>
                <ymin>107</ymin>
                <xmax>368</xmax>
                <ymax>148</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>340</xmin>
                <ymin>12</ymin>
                <xmax>354</xmax>
                <ymax>28</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>390</xmin>
                <ymin>45</ymin>
                <xmax>412</xmax>
                <ymax>83</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>411</xmin>
                <ymin>89</ymin>
                <xmax>430</xmax>
                <ymax>125</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>432</xmin>
                <ymin>94</ymin>
                <xmax>454</xmax>
                <ymax>143</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>453</xmin>
                <ymin>21</ymin>
                <xmax>478</xmax>
                <ymax>63</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>1</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>405</xmin>
                <ymin>1</ymin>
                <xmax>435</xmax>
                <ymax>30</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>1</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>364</xmin>
                <ymin>1</ymin>
                <xmax>384</xmax>
                <ymax>15</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>354</xmin>
                <ymin>19</ymin>
                <xmax>370</xmax>
                <ymax>48</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>342</xmin>
                <ymin>16</ymin>
                <xmax>352</xmax>
                <ymax>48</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>466</xmin>
                <ymin>69</ymin>
                <xmax>491</xmax>
                <ymax>104</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>488</xmin>
                <ymin>27</ymin>
                <xmax>505</xmax>
                <ymax>67</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>1</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>513</xmin>
                <ymin>41</ymin>
                <xmax>527</xmax>
                <ymax>93</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>491</xmin>
                <ymin>105</ymin>
                <xmax>507</xmax>
                <ymax>150</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>1</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>514</xmin>
                <ymin>115</ymin>
                <xmax>527</xmax>
                <ymax>154</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>409</xmin>
                <ymin>134</ymin>
                <xmax>431</xmax>
                <ymax>175</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>380</xmin>
                <ymin>153</ymin>
                <xmax>391</xmax>
                <ymax>187</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>344</xmin>
                <ymin>157</ymin>
                <xmax>367</xmax>
                <ymax>203</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>347</xmin>
                <ymin>207</ymin>
                <xmax>365</xmax>
                <ymax>246</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>316</xmin>
                <ymin>244</ymin>
                <xmax>335</xmax>
                <ymax>274</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>325</xmin>
                <ymin>210</ymin>
                <xmax>344</xmax>
                <ymax>239</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>353</xmin>
                <ymin>269</ymin>
                <xmax>373</xmax>
                <ymax>302</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>339</xmin>
                <ymin>259</ymin>
                <xmax>356</xmax>
                <ymax>296</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>315</xmin>
                <ymin>293</ymin>
                <xmax>337</xmax>
                <ymax>337</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>299</xmin>
                <ymin>340</ymin>
                <xmax>314</xmax>
                <ymax>378</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>317</xmin>
                <ymin>339</ymin>
                <xmax>340</xmax>
                <ymax>383</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>486</xmin>
                <ymin>344</ymin>
                <xmax>517</xmax>
                <ymax>381</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>447</xmin>
                <ymin>301</ymin>
                <xmax>466</xmax>
                <ymax>347</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>396</xmin>
                <ymin>271</ymin>
                <xmax>414</xmax>
                <ymax>311</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>364</xmin>
                <ymin>224</ymin>
                <xmax>387</xmax>
                <ymax>262</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>442</xmin>
                <ymin>231</ymin>
                <xmax>462</xmax>
                <ymax>274</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>406</xmin>
                <ymin>241</ymin>
                <xmax>429</xmax>
                <ymax>279</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>392</xmin>
                <ymin>157</ymin>
                <xmax>412</xmax>
                <ymax>198</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>458</xmin>
                <ymin>188</ymin>
                <xmax>478</xmax>
                <ymax>227</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>429</xmin>
                <ymin>181</ymin>
                <xmax>450</xmax>
                <ymax>226</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>413</xmin>
                <ymin>179</ymin>
                <xmax>431</xmax>
                <ymax>219</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>500</xmin>
                <ymin>250</ymin>
                <xmax>513</xmax>
                <ymax>284</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>496</xmin>
                <ymin>173</ymin>
                <xmax>513</xmax>
                <ymax>209</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>506</xmin>
                <ymin>201</ymin>
                <xmax>526</xmax>
                <ymax>242</ymax>
            </bndbox>
        </object>
        <object>
            <name>person</name>
            <pose>Unspecified</pose>
            <truncated>0</truncated>
            <difficult>0</difficult>
            <bndbox>
                <xmin>37</xmin>
                <ymin>323</ymin>
                <xmax>65</xmax>
                <ymax>354</ymax>
            </bndbox>
        </object>
    </annotation>