Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

xception_ft_model.py 927 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  1. """Todo: add doc."""
  2. if __name__ == "__main__":
  3. import os
  4. import sys
  5. sys.path.append(os.getcwd())
  6. from tensorflow.keras import Sequential
  7. from tensorflow.keras.applications import Xception
  8. from tensorflow.keras.applications.xception import preprocess_input
  9. from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Lambda
  10. def create_xception_ft_model(image_size, num_classes):
  11. """Todo: add doc."""
  12. img_adjust_layer = Lambda(preprocess_input, input_shape=[image_size, image_size, 3])
  13. pretrained_model = Xception(include_top=False)
  14. pretrained_model.trainable = True
  15. # fmt: off
  16. model = Sequential([
  17. img_adjust_layer,
  18. pretrained_model,
  19. GlobalAveragePooling2D(),
  20. Dense(num_classes, activation="softmax")
  21. ])
  22. # fmt: on
  23. model.compile(
  24. optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"]
  25. )
  26. return model
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...