youl commited on
Commit
becf64c
1 Parent(s): 6769354

functions update

Browse files
Files changed (1) hide show
  1. functions.py +4 -21
functions.py CHANGED
@@ -101,14 +101,7 @@ def crop(image,size=1024):
101
  del crop_img
102
  gc.collect()
103
  #sleep(2)
104
- del H
105
- del H1
106
- del H2
107
- del W
108
- del W1
109
- del W2
110
- del h
111
- del w
112
  gc.collect()
113
  sleep(1)
114
  np.save("locations.npy",np.array(locations))
@@ -129,11 +122,7 @@ def inference(image,locations,model,test_transforms,device):
129
  with torch.no_grad():
130
  predictions = model(image_transformed)
131
 
132
- del imgs
133
- del name
134
- del path
135
- del transformed
136
- del image_transformed
137
  gc.collect()
138
  sleep(1)
139
 
@@ -153,10 +142,7 @@ def inference(image,locations,model,test_transforms,device):
153
  label_name = "lab_"+str(location[0])+"_"+str(location[2])+".png"
154
  cv2.imwrite(os.path.join("labels",label_name),img)
155
 
156
- del label_name
157
- del img
158
- del nms_prediction
159
- del predictions
160
  gc.collect()
161
  sleep(1)
162
 
@@ -170,10 +156,7 @@ def create_new_ortho(locations,empty_image):
170
  empty_image[location[0]:location[1],location[2]:location[3],:] = img
171
  if i%300==0:
172
  cv2.imwrite("img.png",empty_image)
173
- del img
174
- del name
175
- del path
176
- del empty_image
177
  gc.collect()
178
  #sleep(1)
179
  empty_image = np.array(cv2.imread("img.png"))
 
101
  del crop_img
102
  gc.collect()
103
  #sleep(2)
104
+ del H,H1,H2,W,W1,W2,h,w
 
 
 
 
 
 
 
105
  gc.collect()
106
  sleep(1)
107
  np.save("locations.npy",np.array(locations))
 
122
  with torch.no_grad():
123
  predictions = model(image_transformed)
124
 
125
+ del imgs,name,path,transformed,image_transformed
 
 
 
 
126
  gc.collect()
127
  sleep(1)
128
 
 
142
  label_name = "lab_"+str(location[0])+"_"+str(location[2])+".png"
143
  cv2.imwrite(os.path.join("labels",label_name),img)
144
 
145
+ del label_name,img,nms_prediction,predictions
 
 
 
146
  gc.collect()
147
  sleep(1)
148
 
 
156
  empty_image[location[0]:location[1],location[2]:location[3],:] = img
157
  if i%300==0:
158
  cv2.imwrite("img.png",empty_image)
159
+ del img,name,path,empty_image
 
 
 
160
  gc.collect()
161
  #sleep(1)
162
  empty_image = np.array(cv2.imread("img.png"))