Skip to content

Commit

Permalink
Fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
zzilch committed Jul 13, 2020
1 parent 89b5806 commit b4fa10a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 42 deletions.
22 changes: 11 additions & 11 deletions Interface/Houseweb/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ def loadMatlabEng():
startengview = time.clock()
global engview
engview = matlab.engine.start_matlab()
engview.addpath(r'../House/align_fp/', nargout=0)
engview.addpath(r'./align_fp/', nargout=0)
endengview = time.clock()
print(' matlab.engineview time: %s Seconds' % (endengview - startengview))


def loadRetrieval():
global tf_train, centroids, clusters
t1 = time.clock()
tf_train = np.load('../House/retrieval/tf_train.npy')
centroids = np.load('../House/retrieval/centroids_train.npy')
clusters = np.load('../House/retrieval/clusters_train.npy')
tf_train = np.load('./retrieval/tf_train.npy')
centroids = np.load('./retrieval/centroids_train.npy')
clusters = np.load('./retrieval/clusters_train.npy')
t2 = time.clock()
print('load tf/centroids/clusters', t2 - t1)

Expand All @@ -60,7 +60,7 @@ def getTestData():
start = time.clock()
global test_data, testNameList, trainNameList

test_data = pickle.load(open('../House/static/Data/data_test_converted.pkl', 'rb'))
test_data = pickle.load(open('./static/Data/data_test_converted.pkl', 'rb'))
test_data, testNameList, trainNameList = test_data['data'], list(test_data['testNameList']), list(
test_data['trainNameList'])
end = time.clock()
Expand All @@ -71,12 +71,12 @@ def getTrainData():
start = time.clock()
global train_data, trainNameList, trainTF, train_data_eNum, train_data_rNum

train_data = pickle.load(open('../House/static/Data/data_train_converted.pkl', 'rb'))
train_data = pickle.load(open('./static/Data/data_train_converted.pkl', 'rb'))
train_data, trainNameList, trainTF = train_data['data'], list(train_data['nameList']), list(train_data['trainTF'])

train_data_eNum = pickle.load(open('../House/static/Data/data_train_eNum.pkl', 'rb'))
train_data_eNum = pickle.load(open('./static/Data/data_train_eNum.pkl', 'rb'))
train_data_eNum = train_data_eNum['eNum']
train_data_rNum = np.load('../House/static/Data/rNum_train.npy')
train_data_rNum = np.load('./static/Data/rNum_train.npy')

end = time.clock()
print('getTrainData time: %s Seconds' % (end - start))
Expand Down Expand Up @@ -235,7 +235,7 @@ def TransGraph(request):

fp_end = mlresult

sio.savemat("../House/static/" + userInfo.split(',')[0].split('.')[0] + ".mat", {"data": fp_end.data})
sio.savemat("./static/" + userInfo.split(',')[0].split('.')[0] + ".mat", {"data": fp_end.data})

data_js = {}
# fp_end hsedge
Expand Down Expand Up @@ -409,7 +409,7 @@ def AdjustGraph(request):
tmp = [x, y, x, h + y]
data_js["windowsline"].append(tmp)

sio.savemat("../House/static/" + testname.split(',')[0].split('.')[0] + ".mat", {"data": fp_end.data})
sio.savemat("./static/" + testname.split(',')[0].split('.')[0] + ".mat", {"data": fp_end.data})

end = time.clock()
print('AdjustGraph time: %s Seconds' % (end - start))
Expand Down Expand Up @@ -594,7 +594,7 @@ def Save_Editbox(request):
fp_end.data.order = np.array(box_order)
fp_end.data.rBoundary = [np.array(rb) for rb in rBoundary]
fp_end.data = add_dw_fp(fp_end.data)
sio.savemat("../House/static/" + userRoomID + ".mat", {"data": fp_end.data})
sio.savemat("./static/" + userRoomID + ".mat", {"data": fp_end.data})
flag=1
return HttpResponse(json.dumps(flag), content_type="application/json")

Expand Down
2 changes: 1 addition & 1 deletion Interface/model/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def load_model():
model = Model()
model.cuda(0)
model.load_state_dict(
torch.load('../House/model/model.pth', map_location={'cuda:0': 'cuda:0'}))
torch.load('./model/model.pth', map_location={'cuda:0': 'cuda:0'}))
model.eval()
return model

Expand Down
73 changes: 43 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ This implementation requires the following dependencies (tested on Window 10):

* Python 3.7

conda create -n Graph2Plan python==3.7
conda activate Graph2Plan

```bash
conda create -n g2p_app python==3.7
conda activate g2p_app
```

* SciPy, Django, Torch, Opencv, Pandas. You can quickly install/update these dependencies by running the following (replace pip with pip3 for Python 3.7):

conda install scipy django pytorch==1.3.1 opencv torchvision==0.4.2 pandas==0.25.3
```bash
conda install django opencv scipy pandas
conda install pytorch==1.3.1 torchvision -c pytorch
```
**Note: there is a fatal bug when using Matlab and pytorch<1.5.0 together on Linux. Please install the latest pytorch 1.5.0+ to use the interface.**

* The matlab engine:
Find the file "setup.py" in <path_to_Matlab>\<version>\extern\engines\python\"
* Install Matlab Python API (Matlab 2019a+ for python 3.7):
Find the file "setup.py" in `<PATH_TO_MATLAB>/<VERSION>/extern/engines/python/`

python setup.py install
```
python setup.py install
```


### Run
Expand All @@ -48,7 +55,9 @@ This implementation requires the following dependencies (tested on Window 10):

* Run project:

python manage.py runserver 0.0.0.0:8000
```bash
python manage.py runserver 0.0.0.0:8000
```
* Open browser: http://127.0.0.1:8000/home

Expand All @@ -57,39 +66,43 @@ This implementation requires the following dependencies (tested on Window 10):
# Network
### Requirements

The same vertion of Scipy, Django, Torch, Opencv, Pandas with the interface
Create a new environment for training.

```
pip install tqdm tensorboardX pytorch-ignite==0.2.1
```
```bash
conda create -n g2p_train python==3.7
conda activate g2p_train
conda install django opencv scipy pandas
conda install pytorch==1.3.1 torchvision==0.4.2 -c pytorch
pip install tqdm tensorboardX pytorch-ignite==0.2.1
```

### Prepare data

**Data format**

```
data.mat
- name: file name in RPLAN dataset
- boundary: (x,y,dir,isNew), first two point indicate the front door
- order: room order for visualization
- rType: room categories
- rBoundary: (x,y), boundary points for each room
- gtBox: (y0,x0,y1,x1), left-top(in) and right-bottom(out) corner of a room, extracted directly from the RPLAN dataset
- gtBoxNew: (x0,y0,x1,y1), extracted after filling the gap between rooms
- rEdge: (u,v,r), room indices and relative position(u relative to v)
```
```
data.mat
- name: file name in RPLAN dataset
- boundary: (x,y,dir,isNew), first two point indicate the front door
- order: room order for visualization
- rType: room categories
- rBoundary: (x,y), boundary points for each room
- gtBox: (y0,x0,y1,x1), left-top(in) and right-bottom(out) corner of a room, extracted directly from the RPLAN dataset
- gtBoxNew: (x0,y0,x1,y1), extracted after filling the gap between rooms
- rEdge: (u,v,r), room indices and relative position(u relative to v)
```

**Split data for training**

```
python split.py
```
```bash
python split.py
```

### Train

```
python train.py
```
```bash
python train.py
```

### Application

Expand Down

0 comments on commit b4fa10a

Please sign in to comment.