ossaili commited on
Commit
9358e26
1 Parent(s): 6f892ad
Files changed (6) hide show
  1. .gitignore +60 -0
  2. app.py +10 -0
  3. helper.py +33 -0
  4. models.py +49 -0
  5. models/EfficientNetV2B0.h5 +3 -0
  6. requirements.txt +91 -0
.gitignore ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ db.sqlite3
5
+ migrations/
6
+ media/
7
+ settings.py
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ env/
14
+ .env/
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *,cover
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Django stuff:
54
+ *.log
55
+
56
+ # Sphinx documentation
57
+ docs/_build/
58
+
59
+ # PyBuilder
60
+ target/
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ import gradio as gr
4
+ from models import efficientnetv2b0_25_arch_styles_Classifier
5
+
6
+
7
+ demo = gr.Interface(
8
+ efficientnetv2b0_25_arch_styles_Classifier, "image", outputs=["text"])
9
+
10
+ demo.launch()
helper.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import tensorflow as tf
4
+
5
+
6
+ def set_tf_loglevel(level):
7
+ if level >= logging.FATAL:
8
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
9
+ if level >= logging.ERROR:
10
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
11
+ if level >= logging.WARNING:
12
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
13
+ else:
14
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '0'
15
+ logging.getLogger('tensorflow').setLevel(level)
16
+
17
+
18
+ def img_to_tensor(path):
19
+ '''
20
+ convert images to tensor
21
+ args:
22
+ path : image file path
23
+ '''
24
+
25
+ img = tf.keras.utils.load_img(
26
+ path,
27
+ color_mode="rgb",
28
+ target_size=(224, 224),
29
+ interpolation="nearest",
30
+ )
31
+ img_arr = tf.keras.utils.img_to_array(img, data_format=None, dtype=None)
32
+ img = tf.expand_dims(img_arr, 0)
33
+ return img
models.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import numpy as np
3
+ import cv2
4
+
5
+
6
+ def outputs(y):
7
+ return {
8
+ "Achaemenid architecture": y[0],
9
+ "American craftsman style": y[1],
10
+ "American Foursquare architecture": y[2],
11
+ "Ancient Egyptian architecture": y[3],
12
+ "Art Deco architecture": y[4],
13
+ "Art Nouveau architecture": y[5],
14
+ "Baroque architecture": y[6],
15
+ "Bauhaus architecture": y[7],
16
+ "Beaux Arts architecture": y[8],
17
+ "Byzantine architecture": y[9],
18
+ "Chicago school_architecture": y[10],
19
+ "Colonial architecture": y[11],
20
+ "Deconstructivism": y[12],
21
+ "Edwardian architecture": y[13],
22
+ "Georgian architecture": y[14],
23
+ "Gothic architecture": y[15],
24
+ "Greek Revival architecture": y[16],
25
+ "International style": y[17],
26
+ "Novelty architecture": y[18],
27
+ "Palladian architecture": y[19],
28
+ "Postmodern architecture": y[20],
29
+ "Queen Anne architecture": y[21],
30
+ "Romanesque architecture": y[22],
31
+ "Russian Revival_architecture": y[23],
32
+ "Tudor Revival architecture": y[24],
33
+ }
34
+
35
+
36
+ def efficientnetv2b0_25_arch_styles_Classifier(image):
37
+ # file_path = f"./images/{file.filename}"
38
+ # with open(file_path, "wb") as f:
39
+ # f.write(file.file.read())
40
+ resized_image = cv2.resize(image, dsize=(
41
+ 224, 224), interpolation=cv2.INTER_CUBIC)
42
+ img = tf.expand_dims(resized_image, 0)
43
+ efficientnetv2b0 = tf.keras.models.load_model(
44
+ "models\EfficientNetV2B0.h5")
45
+
46
+ y = efficientnetv2b0.predict(img).reshape(-1)
47
+ y = (np.round(y, 3)*100).tolist()
48
+
49
+ return outputs(y)
models/EfficientNetV2B0.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5cff674ff44315dd6fe737b4acd94ca9fc3e96f05c3063bfe098584264e82e3
3
+ size 24507440
requirements.txt ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.1.0
2
+ aiohttp==3.8.1
3
+ aiosignal==1.2.0
4
+ analytics-python==1.4.0
5
+ anyio==3.6.1
6
+ astunparse==1.6.3
7
+ async-timeout==4.0.2
8
+ attrs==21.4.0
9
+ backoff==1.10.0
10
+ bcrypt==3.2.2
11
+ cachetools==5.2.0
12
+ certifi==2022.6.15
13
+ cffi==1.15.1
14
+ charset-normalizer==2.1.0
15
+ click==8.1.3
16
+ colorama==0.4.5
17
+ cryptography==37.0.2
18
+ cycler==0.11.0
19
+ fastapi==0.78.0
20
+ ffmpy==0.3.0
21
+ flatbuffers==1.12
22
+ fonttools==4.33.3
23
+ frozenlist==1.3.0
24
+ fsspec==2022.5.0
25
+ gast==0.4.0
26
+ google-auth==2.9.0
27
+ google-auth-oauthlib==0.4.6
28
+ google-pasta==0.2.0
29
+ gradio==3.0.22
30
+ grpcio==1.47.0
31
+ h11==0.12.0
32
+ h5py==3.7.0
33
+ httpcore==0.15.0
34
+ httpx==0.23.0
35
+ idna==3.3
36
+ Jinja2==3.1.2
37
+ keras==2.9.0
38
+ Keras-Preprocessing==1.1.2
39
+ kiwisolver==1.4.3
40
+ libclang==14.0.1
41
+ linkify-it-py==1.0.3
42
+ Markdown==3.3.7
43
+ markdown-it-py==2.1.0
44
+ MarkupSafe==2.1.1
45
+ matplotlib==3.5.2
46
+ mdit-py-plugins==0.3.0
47
+ mdurl==0.1.1
48
+ monotonic==1.6
49
+ multidict==6.0.2
50
+ numpy==1.23.0
51
+ oauthlib==3.2.0
52
+ opencv-python==4.6.0.66
53
+ opt-einsum==3.3.0
54
+ orjson==3.7.5
55
+ packaging==21.3
56
+ pandas==1.4.3
57
+ paramiko==2.11.0
58
+ Pillow==9.1.1
59
+ protobuf==3.19.4
60
+ pyasn1==0.4.8
61
+ pyasn1-modules==0.2.8
62
+ pycparser==2.21
63
+ pycryptodome==3.15.0
64
+ pydantic==1.9.1
65
+ pydub==0.25.1
66
+ PyNaCl==1.5.0
67
+ pyparsing==3.0.9
68
+ python-dateutil==2.8.2
69
+ python-multipart==0.0.5
70
+ pytz==2022.1
71
+ requests==2.28.1
72
+ requests-oauthlib==1.3.1
73
+ rfc3986==1.5.0
74
+ rsa==4.8
75
+ six==1.16.0
76
+ sniffio==1.2.0
77
+ starlette==0.19.1
78
+ tensorboard==2.9.1
79
+ tensorboard-data-server==0.6.1
80
+ tensorboard-plugin-wit==1.8.1
81
+ tensorflow==2.9.1
82
+ tensorflow-estimator==2.9.0
83
+ tensorflow-io-gcs-filesystem==0.26.0
84
+ termcolor==1.1.0
85
+ typing_extensions==4.3.0
86
+ uc-micro-py==1.0.1
87
+ urllib3==1.26.9
88
+ uvicorn==0.18.2
89
+ Werkzeug==2.1.2
90
+ wrapt==1.14.1
91
+ yarl==1.7.2