Egrt commited on
Commit
bdb5637
·
1 Parent(s): 55c5658

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
+ Author: Egrt
3
+ Date: 2022-03-19 10:23:48
4
+ LastEditors: Egrt
5
+ LastEditTime: 2022-03-21 00:05:27
6
+ FilePath: \Luuu\app.py
7
+ '''
8
+
9
+ from gis import GIS
10
+ import gradio as gr
11
+ from huggingface_hub import hf_hub_download
12
+ filepath = hf_hub_download(repo_id="Egrt/Luuuu", filename="GDAL-3.4.1-cp38-cp38-manylinux_2_5_x86_64.whl")
13
+ import os
14
+ os.system('pip install {}'.format(filepath))
15
+ os.system('pip install requirements.txt')
16
+ from zipfile import ZipFile
17
+ gis = GIS()
18
+
19
+
20
+ # --------模型推理---------- #
21
+ def inference(filepath):
22
+ filename, file_list = gis.detect_image(filepath)
23
+ with ZipFile("result.zip", "w") as zipObj:
24
+ zipObj.write(file_list[0], "{}.tif".format(filename+'mask'))
25
+ zipObj.write(file_list[1], "{}.tif".format(filename))
26
+ zipObj.write(file_list[2], "{}.pdf".format(filename))
27
+ zipObj.write(file_list[3], "{}.cpg".format(filename))
28
+ zipObj.write(file_list[4], "{}.dbf".format(filename))
29
+ zipObj.write(file_list[5], "{}.shx".format(filename))
30
+ zipObj.write(file_list[6], "{}.shp".format(filename))
31
+ zipObj.write(file_list[7], "{}.prj".format(filename))
32
+ return "result.zip"
33
+
34
+
35
+ # --------网页信息---------- #
36
+ title = "基于帧场学习的多边形建筑提取"
37
+ description = "目前最先进图像分割模型通常以栅格形式输出分割,但地理信息系统中的应用通常需要矢量多边形。我们在遥感图像中提取建筑物的任务中,将帧场输出添加到深度分割模型中,将预测的帧场与地面实况轮廓对齐,帮助减少深度网络输出与下游任务中输出样式之间的差距。 @Luuuu🐋🐋"
38
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2004.14875' target='_blank'>Polygonization-by-Frame-Field-Learning</a> | <a href='https://github.com/JingyunLiang/SwinIR' target='_blank'>Github Repo</a></p>"
39
+ example_img_dir = 'images'
40
+ example_img_name = os.listdir(example_img_dir)
41
+ examples=[[os.path.join(example_img_dir, image_path)] for image_path in example_img_name if image_path.endswith('.png')]
42
+ gr.Interface(
43
+ inference,
44
+ [gr.inputs.Image(type="filepath", label="待检测图片")],
45
+ gr.outputs.File(label="检测结果"),
46
+ title=title,
47
+ description=description,
48
+ article=article,
49
+ enable_queue=True,
50
+ examples=examples
51
+ ).launch(debug=True)