資源簡介
根據去霧算法對圖像中的PM2.5濃度進行分析,利用機器學習的方法建模進行估計

代碼片段和文件信息
#-*-?coding:utf-8?-*-
from?urllib.request?import?urlretrieve
import?urllib.parse
import?urllib3
import?requests
import?http.cookiejar
from?lxml?import?etree
from?bs4?import?BeautifulSoup
import?pymysql
import?os
import?re
conn?=?pymysql.connect(host=‘localhost‘user=‘root‘passwd=‘w904403‘db=‘pm25data‘port=3306charset=‘utf8‘)
cursor?=?conn.cursor()
#圖片儲存路徑
local=“D:\\100D5300\\“
#?各城市的href
city_href={}
#?各城市的名稱
city_name={}
UserAgent=‘Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/65.0.3325.181?Safari/537.36‘
citys_url=[‘https://tianqi.moji.com/liveview/china/henan‘]
ee=[‘鄭州‘]
#得到各城市信息
def?getCitys(city_url):
????#city_url=“https://tianqi.moji.com/liveview/china/chongqing“
????city_header={?‘User-Agent‘:UserAgent}
????city_req?=?urllib.request.Request(city_url?None?city_header)
????city_response?=?urllib.request.urlopen(city_req)
????city_page?=?city_response.read().decode(‘utf-8‘)
????tree?=?etree.HTML(city_page)
????for?one?in?tree.xpath(‘//div[@class=“city_hot“]‘):
????????city_href=?one.xpath(‘.//li//a/@href‘)
????????city_name=?one.xpath(‘.//li//a/text()‘)
????print(len(city_href))
????return?city_hrefcity_name
#得到圖片的拍攝時間和地點信息
def?get_imgMessage(IDcitynum):
????header_?=?{‘User-Agent‘:UserAgent?}
????files?=?os.listdir(‘D:\\100D5300\\temp‘)
????for?i?in?ID:
????????#?每張圖片的url,從中找到拍攝時間和地點
????????img_url?=?‘https://tianqi.moji.com/liveview/picture/‘?+?ID[i]
????????req_?=?urllib.request.Request(img_url?None?header_)
????????response_?=?urllib.request.urlopen(req_)
????????the_page_?=?response_.read().decode(‘utf-8‘)
????????soup_?=?BeautifulSoup(the_page_?“html.parser“)
????????#?找到拍攝時間
????????img_date?=?soup_.find_all(id=‘picture_info_date‘)
????????#?找到拍攝地點
????????img_place?=?soup_.find_all(id=‘picture_info_addr‘)
????????try:
????????????img_dateMess?=?img_date[0].get_text().split(‘?‘)
????????except:
????????????continue
????????aroundTime?=?img_dateMess[1].split(‘:‘)
????????#?根據拍攝時間對圖片進行過濾
????????hour_time?=?aroundTime[0].split(‘M‘)
????????theImg?=?soup_.find_all(‘div‘?class_=‘scenery_image_detail‘)
????????#?選擇拍攝時間在上午七點到下午五點之間的
????????if?((hour_time[0]?==?‘A‘?and?int(hour_time[1])?>=?9)?or?(hour_time[0]?==?‘P‘?and?int(hour_time[1])?<=?4)):
????????????#?時間段
????????????#print(‘時間:‘+aroundTime[0])
????????????#?年-月-日
????????????#print(‘年月日:‘+img_dateMess[0])
????????????‘‘‘
???????????????以下是重要函數
????????????‘‘‘
????????????#?圖片url
????????????for?Img?in?theImg:
????????????????link?=?Img.find(‘img‘)[‘src‘]
????????????????#將時間字符串轉為標準格式
????????????????tempList=img_dateMess[0].split(‘-‘)
????????????????if?len(tempList[1])==1:
????????????????????tempList[1]=‘0‘+tempList[1]
????????????????if?len(tempList[2])==1:
????????????????????tempList[2]?=?‘0‘?+?tempList[2]
????????????????img_date?=?tempList[0]+‘-‘+tempList[1]+‘-‘+tempList[2]
????????????????totalname=aroundTime[0]+‘#‘+city_name[cit
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-06-18?13:46??基于機器學習的圖像Pm2.5分析系統\
?????目錄???????????0??2018-05-19?16:53??基于機器學習的圖像Pm2.5分析系統\source\
?????目錄???????????0??2018-07-24?09:48??基于機器學習的圖像Pm2.5分析系統\source\模型搭建\
?????文件????????4084??2018-07-24?09:48??基于機器學習的圖像Pm2.5分析系統\source\模型搭建\project1.py
?????目錄???????????0??2018-05-19?16:56??基于機器學習的圖像Pm2.5分析系統\source\模型搭建\非Keras神經網絡方式\
?????文件?????????977??2018-04-28?17:09??基于機器學習的圖像Pm2.5分析系統\source\模型搭建\非Keras神經網絡方式\project2_SVM.py
?????文件????????6505??2018-05-08?06:46??基于機器學習的圖像Pm2.5分析系統\source\模型搭建\非Keras神經網絡方式\TF_project1.py
?????文件????????1104??2018-05-08?03:04??基于機器學習的圖像Pm2.5分析系統\source\模型搭建\非Keras神經網絡方式\project3_Bayes.py
?????目錄???????????0??2018-05-19?16:59??基于機器學習的圖像Pm2.5分析系統\source\模型與界面接口\
?????文件????????2632??2018-05-10?05:09??基于機器學習的圖像Pm2.5分析系統\source\模型與界面接口\Image2Pm.py
?????文件??????895208??2018-05-08?07:04??基于機器學習的圖像Pm2.5分析系統\source\模型與界面接口\pm_model.h5
?????文件?????1548012??2018-05-08?09:36??基于機器學習的圖像Pm2.5分析系統\source\模型與界面接口\testData.npz
?????目錄???????????0??2018-05-20?02:53??基于機器學習的圖像Pm2.5分析系統\source\特征提取\
?????文件????????7392??2018-05-08?07:31??基于機器學習的圖像Pm2.5分析系統\source\特征提取\PM25Test.py
?????目錄???????????0??2018-05-20?02:53??基于機器學習的圖像Pm2.5分析系統\source\特征提取\data\
?????文件?????7920128??2018-05-08?09:05??基于機器學習的圖像Pm2.5分析系統\source\特征提取\data\docDataFile.npy
?????文件???????10028??2018-05-08?09:05??基于機器學習的圖像Pm2.5分析系統\source\特征提取\data\docLabelFile.npy
?????目錄???????????0??2018-05-19?16:58??基于機器學習的圖像Pm2.5分析系統\source\界面\
?????文件????????8153??2018-05-10?07:23??基于機器學習的圖像Pm2.5分析系統\source\界面\form.py
?????目錄???????????0??2018-05-19?16:58??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\
?????文件????????7765??2018-05-09?06:07??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\back.jpg
?????文件????????4287??2017-06-10?11:16??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\searchon.png
?????文件??????130982??2018-05-09?08:14??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\photoInput.gif
?????文件???????19491??2018-05-09?06:02??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\histLogo.png
?????文件???????33085??2018-05-09?06:05??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\pieLogo.png
?????文件????????5321??2018-05-09?05:59??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\fileLogo.png
?????文件???????40446??2018-05-09?06:00??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\LOGO.png
?????文件????????3280??2018-05-09?14:51??基于機器學習的圖像Pm2.5分析系統\source\界面\imageSrc\quit.png
?????文件????????6172??2018-05-10?10:57??基于機器學習的圖像Pm2.5分析系統\source\界面\openfile.py
?????目錄???????????0??2018-05-20?02:52??基于機器學習的圖像Pm2.5分析系統\source\數據采集\
?????文件????????1620??2018-04-29?08:01??基于機器學習的圖像Pm2.5分析系統\source\數據采集\moveFile.py
............此處省略8個文件信息
評論
共有 條評論