Пример #1
0
import scripts.windturbines.functions_pattern_recognition as fpr
imp.reload(fpr)
import pandas as pd
import matplotlib.pyplot as plt

# Get images from raw directory
# Convert to png in temp
# Predict
# If classified, copy

model = models.load_model('models/simple-model-027-0.988224-1.000000.h5')

# within this file, we assess new regions
COUNTRY = "FR"

raw_dir = fpr.get_param(COUNTRY, "PATH_RAW_IMAGES_ASSESSMENT")
temp_dir = fpr.get_param(COUNTRY, "PATH_TEMP")

dirs = os.listdir(raw_dir)

found_turbines = fpr.assess_windparks_country(raw_dir,
                                              dirs,
                                              temp_dir,
                                              model,
                                              threshold=0.05)

found_turbines_pd = pd.DataFrame(found_turbines)

plt.hist(found_turbines_pd.iloc[:, 2])

turbines = [
imp.reload(fpr)
from scripts.windturbines.functions_pattern_recognition import get_param
from scripts.windturbines.functions_pattern_recognition import cop_predict
from scripts.windturbines.functions_pattern_recognition import check_image
from scripts.windturbines.functions_pattern_recognition import read_params
from scripts.windturbines.functions_pattern_recognition import cop

# The path to the directory where the original
# dataset was uncompressed


#t_base_dir='data/windturbines/train'
#v_base_dir='data/windturbines/validation'
COUNTRY = "MIX"

train_dir = get_param(COUNTRY,"PATH_ML_IMAGES_TURBINES_TRAIN")
test_dir = get_param(COUNTRY,"PATH_ML_IMAGES_TURBINES_TEST")
validation_dir = get_param(COUNTRY,"PATH_ML_IMAGES_TURBINES_VALIDATION")

train_no_dir = get_param(COUNTRY,"PATH_ML_IMAGES_NOTURBINES_TRAIN")
test_no_dir = get_param(COUNTRY,"PATH_ML_IMAGES_NOTURBINES_TEST")
validation_no_dir = get_param(COUNTRY,"PATH_ML_IMAGES_NOTURBINES_VALIDATION")


#### delete directories if exist
#### create if not exist

shutil.rmtree(train_dir,ignore_errors=True)
shutil.rmtree(test_dir,ignore_errors=True)
shutil.rmtree(validation_dir,ignore_errors=True)
shutil.rmtree(train_no_dir,ignore_errors=True)
Пример #3
0
import sys
import gdal
import imp

from shutil import copyfile

import scripts.windturbines.functions_pattern_recognition as fpr
imp.reload(fpr)
from scripts.windturbines.functions_pattern_recognition import get_param
from scripts.windturbines.functions_pattern_recognition import cop_predict
from scripts.windturbines.functions_pattern_recognition import check_image
from scripts.windturbines.functions_pattern_recognition import read_params

COUNTRIES = ['AT', 'BR', 'CN', 'FR']

tgt_dir_tb = get_param("MIX", "PATH_RAW_IMAGES_TURBINES")
tgt_dir_notb = get_param("MIX", "PATH_RAW_IMAGES_NOTURBINES")

shutil.rmtree(tgt_dir_tb, ignore_errors=True)
shutil.rmtree(tgt_dir_notb, ignore_errors=True)

os.makedirs(tgt_dir_tb)
os.makedirs(tgt_dir_notb)

quality_check_list = []

for COUNTRY in COUNTRIES:

    print("=================== " + COUNTRY + " ======================")
    src_dir_tb = get_param(COUNTRY,
                           "PATH_RAW_IMAGES_TURBINES_MACHINE_CLASSIFIED")
Пример #4
0
imp.reload(fpr)
import pandas as pd



# Get images from raw directory
# Convert to png in temp
# Predict
# If classified, copy

model = models.load_model('models/simple-model-027-0.988224-1.000000.h5')

# within this file, we assess new regions
COUNTRY = "CN"

raw_dir = fpr.get_param(COUNTRY, "PATH_RAW_IMAGES_ASSESSMENT")
temp_dir = fpr.get_param(COUNTRY, "PATH_TEMP")

dirs = os.listdir(raw_dir)
allResults = []

i=0
found_turbines = fpr.assess_windparks_country(raw_dir, dirs[i:(i+1)],
                                              temp_dir, model)

assessment_out_file = fpr.get_param(COUNTRY, "PATH_RAW_IMAGES_ASSESSMENT") + 
                      "/assessment.csv" 

p = pd.DataFrame(found_turbines)

p.to_csv(assessment_out_file)
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 14 10:52:02 2019

@author: jschmidt
"""

import imp
import scripts.windturbines.functions_pattern_recognition as fpr
imp.reload(fpr)

import pandas as pd

COUNTRY = "CN"

assessment_file = fpr.get_param(
    COUNTRY, "PATH_RAW_IMAGES_ASSESSMENT") + "/assessment.csv"

p = pd.read_csv(assessment_file)

p.columns = ['id', 'lon', 'lat', 'prediction', 'filename', 'park']

p.hist(bins=20)

raw_dir = fpr.get_param(COUNTRY, "PATH_RAW_IMAGES_ASSESSMENT")

sum(p.prediction > 0.5)

fpr.copy_threshold_files(p, 0.5, raw_dir)
imp.reload(fpr)
import pandas as pd



# Get images from raw directory
# Convert to png in temp
# Predict
# If classified, copy

model = models.load_model('models/simple-model-027-0.988224-1.000000.h5')

# within this file, we assess new regions
COUNTRY = "DE"

raw_dir = fpr.get_param(COUNTRY, "PATH_RAW_IMAGES_OSM")
temp_dir = fpr.get_param(COUNTRY, "PATH_TEMP")

lon_lat = pd.read_csv(fpr.get_param(COUNTRY, "FILE_OSM_TURBINE_LOCATIONS"))


files = []

for i in range(lon_lat.shape[0]):
    files.append(str(i + 1) + ".tif")

lon_lat["filenames"] = files

lon_lat["prediction"] = 0

for i in range(len(files)):
######convert to png in temp
######predict
######if classified, copy


model = models.load_model('models/unfreezed-model-0005-0.02.h5')
#model = models.load_model('models/unfreezed-model-0056-0.01.h5')

list_errors = []

C = fpr.COUNTRIES
C = ['BR']

for COUNTRY in C:
    cnt = 0
    raw_dir = get_param(COUNTRY,"PATH_RAW_IMAGES_TURBINES")
    dest_dir = get_param(COUNTRY,"PATH_RAW_IMAGES_TURBINES_MACHINE_CLASSIFIED") 
    temp_dir = get_param(COUNTRY,"PATH_TEMP")

    files = [x for x in os.listdir(raw_dir) if x.endswith(".tif")]

    errors = files.copy()

    for f in files:
        #print(cnt)
    
        res = cop_predict(f,
            0.9,
            raw_dir,
            temp_dir,
            dest_dir,