Files changed (2) hide show
  1. requirements.txt +427 -0
  2. 恶劣天气识别.ipynb +1 -0
requirements.txt ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.2.0
2
+ aeppl==0.0.33
3
+ aesara==2.7.9
4
+ aiohttp==3.8.3
5
+ aiosignal==1.2.0
6
+ alabaster==0.7.12
7
+ albumentations==1.2.1
8
+ altair==4.2.0
9
+ anyio==3.6.1
10
+ appdirs==1.4.4
11
+ arviz==0.12.1
12
+ astor==0.8.1
13
+ astropy==4.3.1
14
+ astunparse==1.6.3
15
+ async-timeout==4.0.2
16
+ asynctest==0.13.0
17
+ atari-py==0.2.9
18
+ atomicwrites==1.4.1
19
+ attrs==22.1.0
20
+ audioread==3.0.0
21
+ autograd==1.5
22
+ Babel==2.10.3
23
+ backcall==0.2.0
24
+ bcrypt==4.0.1
25
+ beautifulsoup4==4.6.3
26
+ bleach==5.0.1
27
+ blis==0.7.8
28
+ bokeh==2.3.3
29
+ branca==0.5.0
30
+ bs4==0.0.1
31
+ CacheControl==0.12.11
32
+ cached-property==1.5.2
33
+ cachetools==4.2.4
34
+ catalogue==2.0.8
35
+ certifi==2022.9.24
36
+ cffi==1.15.1
37
+ cftime==1.6.2
38
+ chardet==3.0.4
39
+ charset-normalizer==2.1.1
40
+ click==7.1.2
41
+ clikit==0.6.2
42
+ cloudpickle==1.5.0
43
+ cmake==3.22.6
44
+ cmdstanpy==1.0.7
45
+ colorcet==3.0.1
46
+ colorlover==0.3.0
47
+ community==1.0.0b1
48
+ confection==0.0.2
49
+ cons==0.4.5
50
+ contextlib2==0.5.5
51
+ convertdate==2.4.0
52
+ crashtest==0.3.1
53
+ crcmod==1.7
54
+ cryptography==38.0.2
55
+ cufflinks==0.17.3
56
+ cvxopt==1.3.0
57
+ cvxpy==1.2.1
58
+ cycler==0.11.0
59
+ cymem==2.0.6
60
+ Cython==0.29.32
61
+ daft==0.0.4
62
+ dask==2022.2.0
63
+ datascience==0.17.5
64
+ debugpy==1.0.0
65
+ decorator==4.4.2
66
+ defusedxml==0.7.1
67
+ descartes==1.1.0
68
+ dill==0.3.5.1
69
+ distributed==2022.2.0
70
+ dlib==19.24.0
71
+ dm-tree==0.1.7
72
+ docutils==0.17.1
73
+ dopamine-rl==1.0.5
74
+ earthengine-api==0.1.326
75
+ easydict==1.10
76
+ ecos==2.0.10
77
+ editdistance==0.5.3
78
+ en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.4.0/en_core_web_sm-3.4.0-py3-none-any.whl
79
+ entrypoints==0.4
80
+ ephem==4.1.3
81
+ et-xmlfile==1.1.0
82
+ etils==0.8.0
83
+ etuples==0.3.8
84
+ fa2==0.3.5
85
+ fastai==2.7.9
86
+ fastapi==0.85.0
87
+ fastcore==1.5.27
88
+ fastdownload==0.0.7
89
+ fastdtw==0.3.4
90
+ fastjsonschema==2.16.2
91
+ fastprogress==1.0.3
92
+ fastrlock==0.8
93
+ feather-format==0.4.1
94
+ ffmpy==0.3.0
95
+ filelock==3.8.0
96
+ firebase-admin==4.4.0
97
+ fix-yahoo-finance==0.0.22
98
+ Flask==1.1.4
99
+ flatbuffers==22.9.24
100
+ folium==0.12.1.post1
101
+ frozenlist==1.3.1
102
+ fsspec==2022.8.2
103
+ future==0.16.0
104
+ gast==0.5.3
105
+ GDAL==2.2.2
106
+ gdown==4.4.0
107
+ gensim==3.6.0
108
+ geographiclib==1.52
109
+ geopy==1.17.0
110
+ gin-config==0.5.0
111
+ glob2==0.7
112
+ google==2.0.3
113
+ google-api-core==1.31.6
114
+ google-api-python-client==1.12.11
115
+ google-auth==1.35.0
116
+ google-auth-httplib2==0.0.4
117
+ google-auth-oauthlib==0.4.6
118
+ google-cloud-bigquery==1.21.0
119
+ google-cloud-bigquery-storage==1.1.2
120
+ google-cloud-core==1.0.3
121
+ google-cloud-datastore==1.8.0
122
+ google-cloud-firestore==1.7.0
123
+ google-cloud-language==1.2.0
124
+ google-cloud-storage==1.18.1
125
+ google-cloud-translate==1.5.0
126
+ google-colab @ file:///colabtools/dist/google-colab-1.0.0.tar.gz
127
+ google-pasta==0.2.0
128
+ google-resumable-media==0.4.1
129
+ googleapis-common-protos==1.56.4
130
+ googledrivedownloader==0.4
131
+ gradio==3.4.1
132
+ graphviz==0.10.1
133
+ greenlet==1.1.3
134
+ grpcio==1.49.1
135
+ gspread==3.4.2
136
+ gspread-dataframe==3.0.8
137
+ gym==0.25.2
138
+ gym-notices==0.0.8
139
+ h11==0.12.0
140
+ h5py==3.1.0
141
+ HeapDict==1.0.1
142
+ hijri-converter==2.2.4
143
+ holidays==0.16
144
+ holoviews==1.14.9
145
+ html5lib==1.0.1
146
+ httpcore==0.15.0
147
+ httpimport==0.5.18
148
+ httplib2==0.17.4
149
+ httplib2shim==0.0.3
150
+ httpstan==4.6.1
151
+ httpx==0.23.0
152
+ humanize==0.5.1
153
+ hyperopt==0.1.2
154
+ idna==2.10
155
+ imageio==2.9.0
156
+ imagesize==1.4.1
157
+ imbalanced-learn==0.8.1
158
+ imblearn==0.0
159
+ imgaug==0.4.0
160
+ importlib-metadata==5.0.0
161
+ importlib-resources==5.9.0
162
+ imutils==0.5.4
163
+ inflect==2.1.0
164
+ intel-openmp==2022.2.0
165
+ intervaltree==2.1.0
166
+ ipykernel==5.3.4
167
+ ipython==7.9.0
168
+ ipython-genutils==0.2.0
169
+ ipython-sql==0.3.9
170
+ ipywidgets==7.7.1
171
+ itsdangerous==1.1.0
172
+ jax==0.3.21
173
+ jaxlib @ https://storage.googleapis.com/jax-releases/cuda11/jaxlib-0.3.20+cuda11.cudnn805-cp37-cp37m-manylinux2014_x86_64.whl
174
+ jieba==0.42.1
175
+ Jinja2==2.11.3
176
+ joblib==1.2.0
177
+ jpeg4py==0.1.4
178
+ jsonschema==4.3.3
179
+ jupyter-client==6.1.12
180
+ jupyter-console==6.1.0
181
+ jupyter-core==4.11.1
182
+ jupyterlab-widgets==3.0.3
183
+ kaggle==1.5.12
184
+ kapre==0.3.7
185
+ keras==2.8.0
186
+ Keras-Preprocessing==1.1.2
187
+ keras-vis==0.4.1
188
+ kiwisolver==1.4.4
189
+ korean-lunar-calendar==0.3.1
190
+ langcodes==3.3.0
191
+ libclang==14.0.6
192
+ librosa==0.8.1
193
+ lightgbm==2.2.3
194
+ linkify-it-py==1.0.3
195
+ llvmlite==0.39.1
196
+ lmdb==0.99
197
+ locket==1.0.0
198
+ logical-unification==0.4.5
199
+ LunarCalendar==0.0.9
200
+ lxml==4.9.1
201
+ Markdown==3.4.1
202
+ markdown-it-py==2.1.0
203
+ MarkupSafe==2.0.1
204
+ marshmallow==3.18.0
205
+ matplotlib==3.2.2
206
+ matplotlib-venn==0.11.7
207
+ mdit-py-plugins==0.3.1
208
+ mdurl==0.1.2
209
+ miniKanren==1.0.3
210
+ missingno==0.5.1
211
+ mistune==0.8.4
212
+ mizani==0.7.3
213
+ mkl==2019.0
214
+ mlxtend==0.14.0
215
+ more-itertools==8.14.0
216
+ moviepy==0.2.3.5
217
+ mpmath==1.2.1
218
+ msgpack==1.0.4
219
+ multidict==6.0.2
220
+ multipledispatch==0.6.0
221
+ multitasking==0.0.11
222
+ murmurhash==1.0.8
223
+ music21==5.5.0
224
+ natsort==5.5.0
225
+ nbconvert==5.6.1
226
+ nbformat==5.6.1
227
+ netCDF4==1.6.1
228
+ networkx==2.6.3
229
+ nibabel==3.0.2
230
+ nltk==3.7
231
+ notebook==5.3.1
232
+ numba==0.56.2
233
+ numexpr==2.8.3
234
+ numpy==1.21.6
235
+ oauth2client==4.1.3
236
+ oauthlib==3.2.1
237
+ okgrade==0.4.3
238
+ opencv-contrib-python==4.6.0.66
239
+ opencv-python==4.6.0.66
240
+ opencv-python-headless==4.6.0.66
241
+ openpyxl==3.0.10
242
+ opt-einsum==3.3.0
243
+ orjson==3.8.0
244
+ osqp==0.6.2.post0
245
+ packaging==21.3
246
+ palettable==3.3.0
247
+ pandas==1.3.5
248
+ pandas-datareader==0.9.0
249
+ pandas-gbq==0.13.3
250
+ pandas-profiling==1.4.1
251
+ pandocfilters==1.5.0
252
+ panel==0.12.1
253
+ param==1.12.2
254
+ paramiko==2.11.0
255
+ parso==0.8.3
256
+ partd==1.3.0
257
+ pastel==0.2.1
258
+ pathlib==1.0.1
259
+ pathy==0.6.2
260
+ patsy==0.5.2
261
+ pep517==0.13.0
262
+ pexpect==4.8.0
263
+ pickleshare==0.7.5
264
+ Pillow==7.1.2
265
+ pip-tools==6.2.0
266
+ plotly==5.5.0
267
+ plotnine==0.8.0
268
+ pluggy==0.7.1
269
+ pooch==1.6.0
270
+ portpicker==1.3.9
271
+ prefetch-generator==1.0.1
272
+ preshed==3.0.7
273
+ prettytable==3.4.1
274
+ progressbar2==3.38.0
275
+ promise==2.3
276
+ prompt-toolkit==2.0.10
277
+ prophet==1.1.1
278
+ protobuf==3.17.3
279
+ psutil==5.4.8
280
+ psycopg2==2.9.3
281
+ ptyprocess==0.7.0
282
+ py==1.11.0
283
+ pyarrow==6.0.1
284
+ pyasn1==0.4.8
285
+ pyasn1-modules==0.2.8
286
+ pycocotools==2.0.5
287
+ pycparser==2.21
288
+ pycryptodome==3.15.0
289
+ pyct==0.4.8
290
+ pydantic==1.9.2
291
+ pydata-google-auth==1.4.0
292
+ pydot==1.3.0
293
+ pydot-ng==2.0.0
294
+ pydotplus==2.0.2
295
+ PyDrive==1.3.1
296
+ pydub==0.25.1
297
+ pyemd==0.5.1
298
+ pyerfa==2.0.0.1
299
+ Pygments==2.6.1
300
+ pygobject==3.26.1
301
+ pylev==1.4.0
302
+ pymc==4.1.4
303
+ PyMeeus==0.5.11
304
+ pymongo==4.2.0
305
+ pymystem3==0.2.0
306
+ PyNaCl==1.5.0
307
+ PyOpenGL==3.1.6
308
+ pyparsing==3.0.9
309
+ pyrsistent==0.18.1
310
+ pysimdjson==3.2.0
311
+ pysndfile==1.3.8
312
+ PySocks==1.7.1
313
+ pystan==3.3.0
314
+ pytest==3.6.4
315
+ python-apt==0.0.0
316
+ python-chess==0.23.11
317
+ python-dateutil==2.8.2
318
+ python-louvain==0.16
319
+ python-multipart==0.0.5
320
+ python-slugify==6.1.2
321
+ python-utils==3.3.3
322
+ pytz==2022.4
323
+ pyviz-comms==2.2.1
324
+ PyWavelets==1.3.0
325
+ PyYAML==6.0
326
+ pyzmq==23.2.1
327
+ qdldl==0.1.5.post2
328
+ qudida==0.0.4
329
+ regex==2022.6.2
330
+ requests==2.23.0
331
+ requests-oauthlib==1.3.1
332
+ resampy==0.4.2
333
+ rfc3986==1.5.0
334
+ rpy2==3.4.5
335
+ rsa==4.9
336
+ scikit-image==0.18.3
337
+ scikit-learn==1.0.2
338
+ scipy==1.7.3
339
+ screen-resolution-extra==0.0.0
340
+ scs==3.2.0
341
+ seaborn==0.11.2
342
+ Send2Trash==1.8.0
343
+ setuptools-git==1.2
344
+ Shapely==1.8.4
345
+ six==1.15.0
346
+ sklearn-pandas==1.8.0
347
+ smart-open==5.2.1
348
+ sniffio==1.3.0
349
+ snowballstemmer==2.2.0
350
+ sortedcontainers==2.4.0
351
+ soundfile==0.11.0
352
+ spacy==3.4.1
353
+ spacy-legacy==3.0.10
354
+ spacy-loggers==1.0.3
355
+ Sphinx==1.8.6
356
+ sphinxcontrib-serializinghtml==1.1.5
357
+ sphinxcontrib-websupport==1.2.4
358
+ SQLAlchemy==1.4.41
359
+ sqlparse==0.4.3
360
+ srsly==2.4.4
361
+ starlette==0.20.4
362
+ statsmodels==0.12.2
363
+ sympy==1.7.1
364
+ tables==3.7.0
365
+ tabulate==0.8.10
366
+ tblib==1.7.0
367
+ tenacity==8.1.0
368
+ tensorboard==2.8.0
369
+ tensorboard-data-server==0.6.1
370
+ tensorboard-plugin-wit==1.8.1
371
+ tensorflow==2.8.2+zzzcolab20220929150707
372
+ tensorflow-datasets==4.6.0
373
+ tensorflow-estimator==2.8.0
374
+ tensorflow-gcs-config==2.8.0
375
+ tensorflow-hub==0.12.0
376
+ tensorflow-io-gcs-filesystem==0.27.0
377
+ tensorflow-metadata==1.10.0
378
+ tensorflow-probability==0.16.0
379
+ termcolor==2.0.1
380
+ terminado==0.13.3
381
+ testpath==0.6.0
382
+ text-unidecode==1.3
383
+ textblob==0.15.3
384
+ thinc==8.1.2
385
+ threadpoolctl==3.1.0
386
+ tifffile==2021.11.2
387
+ toml==0.10.2
388
+ tomli==2.0.1
389
+ toolz==0.12.0
390
+ torch @ https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp37-cp37m-linux_x86_64.whl
391
+ torchaudio @ https://download.pytorch.org/whl/cu113/torchaudio-0.12.1%2Bcu113-cp37-cp37m-linux_x86_64.whl
392
+ torchsummary==1.5.1
393
+ torchtext==0.13.1
394
+ torchvision @ https://download.pytorch.org/whl/cu113/torchvision-0.13.1%2Bcu113-cp37-cp37m-linux_x86_64.whl
395
+ tornado==5.1.1
396
+ tqdm==4.64.1
397
+ traitlets==5.1.1
398
+ tweepy==3.10.0
399
+ typeguard==2.7.1
400
+ typer==0.4.2
401
+ typing-extensions==4.1.1
402
+ tzlocal==1.5.1
403
+ uc-micro-py==1.0.1
404
+ ujson==5.5.0
405
+ uritemplate==3.0.1
406
+ urllib3==1.24.3
407
+ uvicorn==0.18.3
408
+ vega-datasets==0.9.0
409
+ wasabi==0.10.1
410
+ wcwidth==0.2.5
411
+ webargs==8.2.0
412
+ webencodings==0.5.1
413
+ websockets==10.3
414
+ Werkzeug==1.0.1
415
+ widgetsnbextension==3.6.1
416
+ wordcloud==1.8.2.2
417
+ wrapt==1.14.1
418
+ xarray==0.20.2
419
+ xarray-einstats==0.2.2
420
+ xgboost==0.90
421
+ xkit==0.0.0
422
+ xlrd==1.1.0
423
+ xlwt==1.3.0
424
+ yarl==1.8.1
425
+ yellowbrick==1.5
426
+ zict==2.2.0
427
+ zipp==3.8.1
恶劣天气识别.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"},"gpuClass":"standard"},"cells":[{"cell_type":"markdown","metadata":{"id":"D_XJcxqx22uj"},"source":["## Using Gradio to create a simple interface.\n","\n","Check out the library on [github](https://github.com/gradio-app/gradio-UI) and see the [getting started](https://gradio.app/getting_started.html) page for more demos."]},{"cell_type":"markdown","metadata":{"id":"AUHtJ20jYqd9"},"source":["We'll start with a basic function that greets an input name."]},{"cell_type":"markdown","metadata":{"id":"R06dbZZaYJDq"},"source":["Now we'll wrap this function with a Gradio interface."]},{"cell_type":"code","metadata":{"id":"fJUJLWQ92g6R","executionInfo":{"status":"ok","timestamp":1665586405793,"user_tz":-480,"elapsed":4526,"user":{"displayName":"金先生","userId":"07679655535683887373"}}},"source":["!pip install -q gradio"],"execution_count":24,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"uQheRaw5YVTL"},"source":["That's all! Go ahead and open that share link in a new tab. Check out our [getting started](https://gradio.app/getting_started.html) page for more complicated demos."]},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"KlZeF5loRGRe","executionInfo":{"status":"ok","timestamp":1665586415670,"user_tz":-480,"elapsed":2922,"user":{"displayName":"金先生","userId":"07679655535683887373"}},"outputId":"b7fd8261-dbe6-41b4-eddb-3ae1163a83b2"},"execution_count":25,"outputs":[{"output_type":"stream","name":"stdout","text":["Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"]}]},{"cell_type":"code","source":["from keras.datasets import mnist\n","from keras.utils import np_utils\n","from keras.models import Sequential\n","from keras.layers import Dense,Activation"],"metadata":{"id":"4OpspV6iV1wS","executionInfo":{"status":"ok","timestamp":1665586417692,"user_tz":-480,"elapsed":1,"user":{"displayName":"金先生","userId":"07679655535683887373"}}},"execution_count":26,"outputs":[]},{"cell_type":"code","metadata":{"id":"e200MmBU2aLT","executionInfo":{"status":"ok","timestamp":1665586421228,"user_tz":-480,"elapsed":3,"user":{"displayName":"金先生","userId":"07679655535683887373"}}},"source":["# import gradio\n","# gradio.Interface(greet, \"text\", \"text\").launch(share=True)\n","from keras.models import load_model\n","#import tensorflow as tf\n","# 替换自己的模型\n","#inception_net = tf.keras.applications.MobileNetV2()\n"],"execution_count":27,"outputs":[]},{"cell_type":"code","source":["from keras.models import load_model\n","import numpy as np\n","from keras.preprocessing import image\n","from keras.preprocessing.image import load_img\n","from PIL import ImageFilter\n","from PIL import Image\n","import cv2\n","import os\n","\n","#PHOTO_SIZE = 120 #对图片大小进行限制,低于120KB的抛弃\n","#path = r'/content/sunny.jpg' # 目标\n","weight_path = r'/content/drive/MyDrive/恶劣天气图像识别代码-毕业设计-戴一凡/basic.h5' #权重文件\n","\n","#re_x =256 #输入到神经网络中的文件的大小\n","\n","model = load_model(weight_path)\n","#img = Image.open(path)\n","#img = img.resize((re_x,re_x), Image.ANTIALIAS) #缩放到事先指定的大小\n","#img = np.expand_dims(img, axis=0)\n","#print(img)\n","#inception_net=model.predict(img)#获取预测值\n"],"metadata":{"id":"V1H-DJgUZ3YX","executionInfo":{"status":"ok","timestamp":1665586434870,"user_tz":-480,"elapsed":1729,"user":{"displayName":"金先生","userId":"07679655535683887373"}}},"execution_count":28,"outputs":[]},{"cell_type":"code","source":["#labels =['Srainy', 'Mrainy', 'Lrainy', 'Sfoggy', 'Mfoggy','Lfoggy','sunny']\n","labels=['天气:小雨, 降雨强度(mm/min):0.8, 能见度(m):500, 道路摩擦系数:0.64, 限速(km/h):80',\n"," '天气:中雨, 降雨强度(mm/min):1.2, 能见度(m):250, 道路摩擦系数:0.58, 限速(km/h):50',\n"," '天气:大雨, 降雨强度(mm/min):1.6, 能见度(m):50-150, 道路摩擦系数:0.45, 限速(km/h):30',\n"," '天气:薄雾, 降雨强度(mm/min):0, 能见度(m):500:, 道路摩擦系数:0.8, 限速(km/h):110',\n"," '天气:大雾, 降雨强度(mm/min):0, 能见度(m):200, 道路摩擦系数:0.8, 限速(km/h):70',\n"," '天气:浓雾, 降雨强度(mm/min):0:, 能见度(m):50-100, 道路摩擦系数:0.8, 限速(km/h):40',\n"," '天气:晴, 降雨强度(mm/min):0, 能见度(m):>1000:, 道路摩擦系数:0.8, 限速(km/h):120']\n","def classify_image(inp):\n"," inp = inp.resize((256,256), Image.ANTIALIAS) #缩放到事先指定的大小\n"," inp = np.expand_dims(inp, axis=0)\n"," prediction = model.predict(inp)\n"," confidences = {labels[i]: float(prediction[0][i]) for i in range(7)}\n"," return confidences\n","#path = r'/content/rainy.jpg'\n","\n","#img = Image.open(path)\n","#print(classify_image(img))"],"metadata":{"id":"Og4_R6lN49al","executionInfo":{"status":"ok","timestamp":1665586436812,"user_tz":-480,"elapsed":1,"user":{"displayName":"金先生","userId":"07679655535683887373"}}},"execution_count":29,"outputs":[]},{"cell_type":"code","source":["import gradio as gr\n","gr.Interface(\n"," fn=classify_image,\n"," inputs=gr.Image(type=\"pil\",shape=(256,256)),\n"," outputs=gr.Label(num_top_classes=1),\n"," examples=[\"rainy.jpg\", \"sunny.jpg\"],\n"," interpretation=\"default\",cache_examples=True,title=\"恶劣天气图像识别与预警\"\n",").launch(enable_queue=True)"],"metadata":{"id":"8Ls0etEpC1h4","colab":{"base_uri":"https://localhost:8080/","height":660},"executionInfo":{"status":"ok","timestamp":1665587091024,"user_tz":-480,"elapsed":9765,"user":{"displayName":"金先生","userId":"07679655535683887373"}},"outputId":"c70b2110-b366-4116-92e0-3cbde69eece0"},"execution_count":36,"outputs":[{"output_type":"stream","name":"stdout","text":["Caching examples at: '/content/gradio_cached_examples/66/log.csv'\n","Colab notebook detected. To show errors in colab notebook, set `debug=True` in `launch()`\n","Running on public URL: https://18698.gradio.app\n","\n","This share link expires in 72 hours. For free permanent hosting, check out Spaces: https://huggingface.co/spaces\n"]},{"output_type":"display_data","data":{"text/plain":["<IPython.core.display.HTML object>"],"text/html":["<div><iframe src=\"https://18698.gradio.app\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"]},"metadata":{}},{"output_type":"execute_result","data":{"text/plain":["(<gradio.routes.App at 0x7f839f968d50>,\n"," 'http://127.0.0.1:7862/',\n"," 'https://18698.gradio.app')"]},"metadata":{},"execution_count":36}]},{"cell_type":"code","source":["import gradio as gr\n","def generate_mutimodal(title, context, senti, num, img):\n"," return f\"Title:{title}\\nContext:{context}\\nSenti:{senti}\\nNum:{num}...{img}\"\n"," \n","server = gr.Interface(\n"," fn=generate_mutimodal, \n"," inputs=[\n"," gr.Textbox(lines=1, placeholder=\"请输入标题\", label=\"标题\", interactive=True), # interactive指定该组件是否允许用户输入或者交互\n"," gr.Textbox(lines=2, placeholder=\"请输入正文\", label=\"正文\"),\n"," gr.Radio([\"0\", \"1\", \"随机\"], label=\"倾向\"),\n"," gr.Number(label='条数'),\n"," gr.Image(shape=(200, 200), label=\"请上传图片(可选)\").style(height='24', rounded=True)\n"," ], \n"," outputs=\"text\",\n"," examples=[\n"," [\"标题1\", \"正文1\", \"0\", None],\n"," [\"标题2\", \"正文2\", \"随机\"],\n"," ],\n"," title=\"可控文本生成\",\n"," description=\"标题和正文至少一个非空,图片可选是否上传\",\n"," article=\"\"\"\n"," ### 这里是底部的article\n"," #### article 1\n"," This is article 1\n"," \"\"\",\n"," css=\"body {background-color: red; font-size: large}\",\n"," allow_flagging=\"never\", # 输出侧是否开启flag功能 比如让用户去标记输出结果是否正确 写到日志\n"," live=False, # live: 用户输入改变时是否自动计算结果\n"," cache_examples=False, # cache_examples: 是否将example里的结果提前算好存到缓存里\n",")\n","\n","server.launch(\n"," enable_queue=False, # enable_queue: 如果app流量很大,需设置参数以防止超时。这将使用长轮询对调用进行排队,一次仅处理一个调用。长轮询还可以防止网络超时,因此,如果函数的推理时间很长(> 1 分钟),则应使用队列。\n"," auth=(\"admin\", \"admin\"), # auth: 参数值可以是 (user, pwd) 的元组,也可以是一个函数名(用户名和密码是参数, 并返回 True/False)。enable_queue=True 时,auth不能传元组。\n"," share=True # share: 可生成 72h 的公网访问地址,原理相当于 gradio 提供了一个内网穿透的代理,并没有把代码+环境上传到他们服务器\n",")\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"h0SZKbaerIST","executionInfo":{"status":"ok","timestamp":1665552816914,"user_tz":-480,"elapsed":5630,"user":{"displayName":"金先生","userId":"07679655535683887373"}},"outputId":"6e12b243-6d41-4fcb-ecce-c27255a0b8f7"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stderr","text":["/usr/local/lib/python3.7/dist-packages/gradio/components.py:197: UserWarning: 'rounded' styling is no longer supported. To round adjacent components together, place them in a Column(variant='box').\n"," \"'rounded' styling is no longer supported. To round adjacent components together, place them in a Column(variant='box').\"\n"]},{"output_type":"stream","name":"stdout","text":["Colab notebook detected. To show errors in colab notebook, set `debug=True` in `launch()`\n","Running on public URL: https://17915.gradio.app\n","\n","This share link expires in 72 hours. For free permanent hosting, check out Spaces: https://huggingface.co/spaces\n"]},{"output_type":"execute_result","data":{"text/plain":["(<gradio.routes.App at 0x7f9d6e3bfb10>,\n"," 'http://127.0.0.1:7861/',\n"," 'https://17915.gradio.app')"]},"metadata":{},"execution_count":7}]},{"cell_type":"code","source":[],"metadata":{"id":"t86gBSOLMFmX"},"execution_count":null,"outputs":[]}]}