zlzeng / DeepFloorplan

GNU General Public License v3.0
270 stars 103 forks source link

How I solve the problem about r2v dataset and roomtype error #17

Open krus1995 opened 3 years ago

krus1995 commented 3 years ago

First of all, thanks to @zlzeng sent me txt of origin name by correct order, which give me feasibility to modify these files into correct correspondence. If you need the raw txt, check the file below. test.txt train.txt val.txt

If you don't want to know what happens, just find the summary in the end.

To train model with r2v dataset, we need to correct the correspondence in txt file and change a little bit code. Let's see how to get through this. You can download r2v origin data from here.

Modify txt file First I merged zlzeng's txt and project's txt, the result looks like:

../dataset/floorplan_image/04/94/1b4b5b3a8dcbe2135310d067eb6e/0001.jpg ../dataset/jp/test/1_wall.png ../dataset/jp/test/1_close.png ../dataset/jp/test/1_rooms.png ../dataset/jp/test/1_close_wall.png ../dataset/floorplan_image/08/fe/cb1ded96be76713683c50e731f3f/0001.jpg ../dataset/jp/test/2_wall.png ../dataset/jp/test/2_close.png ../dataset/jp/test/2_rooms.png ../dataset/jp/test/2_close_wall.png ../dataset/floorplan_image/04/8c/723a3389ae4aaaa11d3d97123e2d/0001.jpg ../dataset/jp/test/3_wall.png ../dataset/jp/test/3_close.png ../dataset/jp/test/3_rooms.png ../dataset/jp/test/3_close_wall.png ../dataset/floorplan_image/03/c0/fd5d2bb20c86db0c8f24a83b8a3c/0003.jpg ../dataset/jp/test/4_wall.png ../dataset/jp/test/4_close.png ../dataset/jp/test/4_rooms.png ../dataset/jp/test/4_close_wall.png ../dataset/floorplan_image/00/23/500a167ab926df601817631d6733/0002.jpg ../dataset/jp/test/5_wall.png ../dataset/jp/test/5_close.png ../dataset/jp/test/5_rooms.png ../dataset/jp/test/5_close_wall.png ../dataset/floorplan_image/01/e5/df6969c71c4cb3b786cde09b4efc/0002.jpg ../dataset/jp/test/6_wall.png ../dataset/jp/test/6_close.png ../dataset/jp/test/6_rooms.png ../dataset/jp/test/6_close_wall.png ../dataset/floorplan_image/08/3c/4144463ce4d677723e9032358408/0002.jpg ../dataset/jp/test/7_wall.png ../dataset/jp/test/7_close.png ../dataset/jp/test/7_rooms.png ../dataset/jp/test/7_close_wall.png ../dataset/floorplan_image/09/22/b9bd969fff7820dbdbc660b6df26/0001.jpg ../dataset/jp/test/8_wall.png ../dataset/jp/test/8_close.png ../dataset/jp/test/8_rooms.png ../dataset/jp/test/8_close_wall.png ../dataset/floorplan_image/02/d4/6ab7b8396d8f24c31ea2e8a0e2f2/0003.jpg ../dataset/jp/test/9_wall.png ../dataset/jp/test/9_close.png ../dataset/jp/test/9_rooms.png ../dataset/jp/test/9_close_wall.png ../dataset/floorplan_image/00/99/28fbde7b272adad6da35f0bc16c3/0001.jpg ../dataset/jp/test/10_wall.png ../dataset/jp/test/10_close.png ../dataset/jp/test/10_rooms.png ../dataset/jp/test/10_close_wall.png

Then I try to run main.py --phase test, it works well but when I check ./out directory, I found that results were overwritten by itself because of the name of origin file is almost the same like 0001.jpg. So we have to change name of images and path in txt. I write a simple script to do this task:

Before running the script below, you should download those files and put it into ./dataset r2v_train.txt r2v_test.txt

# DeepFloorplan/utils/txt_modify.py
import os

TRAIN_TXT = "r2v_train.txt"
TEST_TXT = "r2v_test.txt"

if __name__ == "__main__":
    for txt_name in [TRAIN_TXT, TEST_TXT]:
        root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../dataset"))
        print(root_path)
        txt_path = os.path.join(root_path, txt_name)
        print(txt_path)

        with open(txt_path) as file:
            lines = file.read().splitlines()

        path = [[line.split("\t")[0], line.split("\t")[1]] for line in lines]

        target_path = []
        for origin, target in path:
            root, origin_name = os.path.split(origin)
            target_name = os.path.basename(target).split("_")[0] + ".jpg"

            try:
                os.rename(origin, os.path.join(root, target_name))
            except OSError:
                print("No such file or directory {}".format(origin))

            target_path.append(os.path.join(root, target_name))

        path = [line.split("\t") for line in lines]
        for line, target_path in zip(path, target_path):
            line[0] = target_path

        with open(txt_name, "w+") as file:
            for line in path:
                file.write("\t".join(line))
                file.write("\r\n")

When I run this script I got an IO Error so I add try block to figure out what happened:

No such file or directory ../dataset/floorplan_image/04/94/1b4b5b3a8dcbe2135310d067eb6e/1.jpg No such file or directory ../dataset/floorplan_image/08/fe/cb1ded96be76713683c50e731f3f/2.jpg No such file or directory ../dataset/floorplan_image/04/8c/723a3389ae4aaaa11d3d97123e2d/3.jpg No such file or directory ../dataset/floorplan_image/03/c0/fd5d2bb20c86db0c8f24a83b8a3c/4.jpg No such file or directory ../dataset/floorplan_image/00/23/500a167ab926df601817631d6733/5.jpg No such file or directory ../dataset/floorplan_image/01/e5/df6969c71c4cb3b786cde09b4efc/6.jpg No such file or directory ../dataset/floorplan_image/08/3c/4144463ce4d677723e9032358408/7.jpg No such file or directory ../dataset/floorplan_image/09/22/b9bd969fff7820dbdbc660b6df26/8.jpg No such file or directory ../dataset/floorplan_image/02/d4/6ab7b8396d8f24c31ea2e8a0e2f2/9.jpg No such file or directory ../dataset/floorplan_image/00/99/28fbde7b272adad6da35f0bc16c3/10.jpg

Seem like we loss 10 images. I checked directory and find out that there are ten duplication usages in txt file. These ten images are used in both training and test task.

To solve this problem, we have three choices (I choose solution 2)

  1. Training a model use first merged txt file (without change filename)
  2. copy these images and rename it by yourself
  3. find all code of read image and use try block to catch the error

Finally, we have correct txt file and ready for training. Before training in large dataset, you should check the output of model whether room type can be predicted.

Modify code If the room type can't be predicted, replaceself.loss_type = 'balanced' in main.py with self.loss_type = ''. More information please check this issue.

Simple version To summarize, you should

  1. download r2v origin data from here
  2. download the txt file and put it into ./dataset r2v_train.txt r2v_test.txt
  3. run the script and solve the duplication problem
  4. follow "the steps of training and validation in this project"

Those are the steps of training and validation in this project

  1. prepare data and txt
  2. run ./utils/create_tfrecord.py to create tfrecord of data (r2v or r3d)
  3. run ./main.py --phase train (sr2v or r3d)
  4. run ./main.py --phase test (r2v or r3d)
  5. check result from ./out
  6. run ./scores.py for calculate ACC and IoU

Hope helpful. Please reply if there are any mistake or suggestion.

Flyingdog-Huang commented 2 years ago

hi, I can not find any train-input-img in r2v image

krus1995 commented 2 years ago

hi, I can not find any train-input-img in r2v image

I remember the "train input image" is these "_multi" images.

zlzeng commented 2 years ago

Hi,

We don't have permission to share the raw image data, so please download the LIFULL dataset from their official site.

Best, ZENG Zhiliang

On Thu, 11 Nov 2021 at 09:53, Krus @.***> wrote:

hi, I can not find any train-input-img in r2v [image: image] https://user-images.githubusercontent.com/43697342/141139810-205c7f30-7d49-4efc-ba06-b6427a6f6186.png

I remember the "train input image" is these "_multi" images.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zlzeng/DeepFloorplan/issues/17#issuecomment-965920146, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADKIF4MNQ4UYQNVPN24LBALULMO2DANCNFSM45B3XMVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Flyingdog-Huang commented 2 years ago

ok, thanks a lot

---Original--- From: @.> Date: Thu, Nov 11, 2021 20:07 PM To: @.>; Cc: @.**@.>; Subject: Re: [zlzeng/DeepFloorplan] How I solve the problem about r2v dataset and roomtype error (#17)

Hi,

We don't have permission to share the raw image data, so please download the LIFULL dataset from their official site.

Best, ZENG Zhiliang

On Thu, 11 Nov 2021 at 09:53, Krus @.***> wrote:

> hi, I can not find any train-input-img in r2v [image: image] > <https://user-images.githubusercontent.com/43697342/141139810-205c7f30-7d49-4efc-ba06-b6427a6f6186.png&gt; > > I remember the "train input image" is these "_multi" images. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/zlzeng/DeepFloorplan/issues/17#issuecomment-965920146&gt;, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ADKIF4MNQ4UYQNVPN24LBALULMO2DANCNFSM45B3XMVQ&gt; > . > Triage notifications on the go with GitHub Mobile for iOS > <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&amp;mt=8&amp;pt=524675&gt; > or Android > <https://play.google.com/store/apps/details?id=com.github.android&amp;referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub&gt;. > >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Flyingdog-Huang commented 2 years ago

hi, if I want to get the R2V data set , Who should I send the application email to? THX

------------------ 原始邮件 ------------------ 发件人: "zlzeng/DeepFloorplan" @.>; 发送时间: 2021年11月11日(星期四) 晚上8:07 @.>; @.**@.>; 主题: Re: [zlzeng/DeepFloorplan] How I solve the problem about r2v dataset and roomtype error (#17)

Hi,

We don't have permission to share the raw image data, so please download the LIFULL dataset from their official site.

Best, ZENG Zhiliang

On Thu, 11 Nov 2021 at 09:53, Krus @.***> wrote:

> hi, I can not find any train-input-img in r2v [image: image] > <https://user-images.githubusercontent.com/43697342/141139810-205c7f30-7d49-4efc-ba06-b6427a6f6186.png&gt; > > I remember the "train input image" is these "_multi" images. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/zlzeng/DeepFloorplan/issues/17#issuecomment-965920146&gt;, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ADKIF4MNQ4UYQNVPN24LBALULMO2DANCNFSM45B3XMVQ&gt; > . > Triage notifications on the go with GitHub Mobile for iOS > <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&amp;mt=8&amp;pt=524675&gt; > or Android > <https://play.google.com/store/apps/details?id=com.github.android&amp;referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub&gt;. > >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

johoye123 commented 2 weeks ago

No such file or directory ../dataset/floorplan_image/04/94/1b4b5b3a8dcbe2135310d067eb6e/1.jpg No such file or directory ../dataset/floorplan_image/08/fe/cb1ded96be76713683c50e731f3f/2.jpg No such file or directory ../dataset/floorplan_image/04/8c/723a3389ae4aaaa11d3d97123e2d/3.jpg

Where can I find these JPG files? thank you!

abner2015 commented 2 weeks ago

http://pan.baidu.com/s/1hqGbyQS

johoye123 commented 2 weeks ago

Thank you, but the link has expired! @abner2015

johoye123 commented 2 weeks ago

http://pan.baidu.com/s/1hqGbyQS

Hi abner2015

Please help me, thank you!