File tree Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,5 @@ __pycache__/
5
5
* .json
6
6
tmp /
7
7
* .log
8
+ fred /inference /model_files.bz2
9
+ fred /inference /model_files /* .pth
Original file line number Diff line number Diff line change @@ -47,18 +47,19 @@ def predict(image_file):
47
47
model = NNet ()
48
48
model .load_state_dict (torch .load (model_path , map_location = 'cpu' ))
49
49
model .eval ()
50
-
51
- pilim = Image .open (image_file ).convert ('L' ).convert ('RGB' )
52
- pilim = preprocess_pilim (pilim )
53
- input_array = prepare_for_input (pilim , flip_lr = False )
54
-
55
- lr_input_array = prepare_for_input (pilim , flip_lr = True )
56
- try :
57
- out_array = get_output (model (get_tensor (input_array )))
58
- except :
59
- exit (2 )
60
-
61
- lr_out_array = np .fliplr (get_output (model (get_tensor (lr_input_array ))))
50
+
51
+ with torch .no_grad ():
52
+ pilim = Image .open (image_file ).convert ('L' ).convert ('RGB' )
53
+ pilim = preprocess_pilim (pilim )
54
+ input_array = prepare_for_input (pilim , flip_lr = False )
55
+
56
+ lr_input_array = prepare_for_input (pilim , flip_lr = True )
57
+ try :
58
+ out_array = get_output (model (get_tensor (input_array )))
59
+ except :
60
+ exit (2 )
61
+
62
+ lr_out_array = np .fliplr (get_output (model (get_tensor (lr_input_array ))))
62
63
63
64
out_array = (out_array + lr_out_array ) / 2
64
65
out_array = threshold_output (out_array , 0.5 )
Original file line number Diff line number Diff line change @@ -8,4 +8,5 @@ Flask_Cors==3.0.8
8
8
numpy == 1.17.1
9
9
Pillow == 6.1.0
10
10
beautifulsoup4 == 4.8.0
11
- pyppeteer == 0.0.25
11
+ pyppeteer == 0.0.25
12
+ websockets == 6.0
You can’t perform that action at this time.
0 commit comments