Daniel Verdu commited on
Commit
be5401f
1 Parent(s): eb91312

merged changes

Browse files
Files changed (1) hide show
  1. deoldify/generators.py +0 -68
deoldify/generators.py CHANGED
@@ -1,53 +1,11 @@
1
- <<<<<<< HEAD
2
- from fastai.basics import F, nn
3
- from fastai.basic_data import DataBunch
4
- from fastai.basic_train import Learner
5
- from fastai.layers import NormType
6
- from fastai.torch_core import SplitFuncOrIdxList, to_device, apply_init
7
- from fastai.vision import *
8
- from fastai.vision.learner import cnn_config, create_body
9
- =======
10
  from fastai.vision import *
11
  from fastai.vision.learner import cnn_config
12
- >>>>>>> 878ecf212e9f3f2f6e923e3bfff6ec899dc40143
13
  from .unet import DynamicUnetWide, DynamicUnetDeep
14
  from .loss import FeatureLoss
15
  from .dataset import *
16
 
17
  # Weights are implicitly read from ./models/ folder
18
  def gen_inference_wide(
19
- <<<<<<< HEAD
20
- root_folder: Path, weights_name: str, nf_factor: int = 2,
21
- arch=models.resnet101
22
- ) -> Learner:
23
-
24
- data = get_dummy_databunch()
25
- learn = gen_learner_wide(data=data, gen_loss=F.l1_loss, nf_factor=nf_factor, arch=arch)
26
- learn = get_inference(learn, root_folder, weights_name)
27
- return learn
28
-
29
- def gen_inference_deep(root_folder: Path, weights_name: str,
30
- arch=models.resnet34, nf_factor: float = 1.5
31
- ) -> Learner:
32
-
33
- data = get_dummy_databunch()
34
- learn = gen_learner_deep(data=data, gen_loss=F.l1_loss, arch=arch, nf_factor=nf_factor)
35
- learn = get_inference(learn, root_folder, weights_name)
36
- return learn
37
-
38
- # Weights are implicitly read from ./models/ folder
39
- # Load loads weights from os.path.join(learner.path, learner.model_dir, weights_name)
40
- def get_inference(learn, root_folder, weights_name) -> Learner:
41
- learn.path = root_folder
42
- try:
43
- learn.load(weights_name)
44
- print('Model loaded successfully')
45
- except Exception as e:
46
- print(e)
47
- print('Error while reading the model')
48
- learn.model.eval()
49
-
50
- =======
51
  root_folder: Path, weights_name: str, nf_factor: int = 2, arch=models.resnet101) -> Learner:
52
  data = get_dummy_databunch()
53
  learn = gen_learner_wide(
@@ -56,7 +14,6 @@ def get_inference(learn, root_folder, weights_name) -> Learner:
56
  learn.path = root_folder
57
  learn.load(weights_name)
58
  learn.model.eval()
59
- >>>>>>> 878ecf212e9f3f2f6e923e3bfff6ec899dc40143
60
  return learn
61
 
62
 
@@ -120,12 +77,6 @@ def unet_learner_wide(
120
 
121
  # ----------------------------------------------------------------------
122
 
123
- <<<<<<< HEAD
124
- def gen_learner_deep(data: ImageDataBunch, gen_loss, arch=models.resnet34,
125
- nf_factor: float = 1.5
126
- ) -> Learner:
127
-
128
- =======
129
  # Weights are implicitly read from ./models/ folder
130
  def gen_inference_deep(
131
  root_folder: Path, weights_name: str, arch=models.resnet34, nf_factor: float = 1.5) -> Learner:
@@ -142,7 +93,6 @@ def gen_inference_deep(
142
  def gen_learner_deep(
143
  data: ImageDataBunch, gen_loss, arch=models.resnet34, nf_factor: float = 1.5
144
  ) -> Learner:
145
- >>>>>>> 878ecf212e9f3f2f6e923e3bfff6ec899dc40143
146
  return unet_learner_deep(
147
  data,
148
  arch,
@@ -158,23 +108,6 @@ def gen_learner_deep(
158
 
159
  # The code below is meant to be merged into fastaiv1 ideally
160
  def unet_learner_deep(
161
- <<<<<<< HEAD
162
- data: DataBunch,
163
- arch: Callable,
164
- pretrained: bool = True,
165
- blur_final: bool = True,
166
- norm_type: Optional[NormType] = NormType,
167
- split_on: Optional[SplitFuncOrIdxList] = None,
168
- blur: bool = False,
169
- self_attention: bool = False,
170
- y_range: Optional[Tuple[float, float]] = None,
171
- last_cross: bool = True,
172
- bottle: bool = False,
173
- nf_factor: float = 1.5,
174
- **kwargs: Any
175
- ) -> Learner:
176
-
177
- =======
178
  data: DataBunch,
179
  arch: Callable,
180
  pretrained: bool = True,
@@ -189,7 +122,6 @@ def unet_learner_deep(
189
  nf_factor: float = 1.5,
190
  **kwargs: Any
191
  ) -> Learner:
192
- >>>>>>> 878ecf212e9f3f2f6e923e3bfff6ec899dc40143
193
  "Build Unet learner from `data` and `arch`."
194
  meta = cnn_config(arch)
195
  body = create_body(arch, pretrained)
 
 
 
 
 
 
 
 
 
 
1
  from fastai.vision import *
2
  from fastai.vision.learner import cnn_config
 
3
  from .unet import DynamicUnetWide, DynamicUnetDeep
4
  from .loss import FeatureLoss
5
  from .dataset import *
6
 
7
  # Weights are implicitly read from ./models/ folder
8
  def gen_inference_wide(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  root_folder: Path, weights_name: str, nf_factor: int = 2, arch=models.resnet101) -> Learner:
10
  data = get_dummy_databunch()
11
  learn = gen_learner_wide(
 
14
  learn.path = root_folder
15
  learn.load(weights_name)
16
  learn.model.eval()
 
17
  return learn
18
 
19
 
 
77
 
78
  # ----------------------------------------------------------------------
79
 
 
 
 
 
 
 
80
  # Weights are implicitly read from ./models/ folder
81
  def gen_inference_deep(
82
  root_folder: Path, weights_name: str, arch=models.resnet34, nf_factor: float = 1.5) -> Learner:
 
93
  def gen_learner_deep(
94
  data: ImageDataBunch, gen_loss, arch=models.resnet34, nf_factor: float = 1.5
95
  ) -> Learner:
 
96
  return unet_learner_deep(
97
  data,
98
  arch,
 
108
 
109
  # The code below is meant to be merged into fastaiv1 ideally
110
  def unet_learner_deep(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  data: DataBunch,
112
  arch: Callable,
113
  pretrained: bool = True,
 
122
  nf_factor: float = 1.5,
123
  **kwargs: Any
124
  ) -> Learner:
 
125
  "Build Unet learner from `data` and `arch`."
126
  meta = cnn_config(arch)
127
  body = create_body(arch, pretrained)