sprite33 commited on
Commit
7648841
·
1 Parent(s): 0c19d6f
Files changed (1) hide show
  1. app.py +55 -51
app.py CHANGED
@@ -9,59 +9,63 @@ def load_model():
9
  return loaded_pipeline
10
 
11
  # 예측 함수 정의
12
- def predict(construction_type, underground_floors, aboveground_floors, total_area,
13
- land_area, building_area, landscape_area, parking_lot_count, order_year,
14
- order_month, construction_period, location, building_purpose):
15
-
16
  new_project = {
17
- '구조': [construction_type],
18
- '지하층수': [underground_floors],
19
- '지상층수': [aboveground_floors],
20
- '연면적': [total_area],
21
- '대지면적': [land_area],
22
- '건축면적': [building_area],
23
- '조경면적': [landscape_area],
24
- '주차수': [parking_lot_count],
25
- '발주년': [order_year],
26
- '발주월': [order_month],
27
- '공사기간': [construction_period],
28
- '현장위치': [location],
29
- '건축법상용도': [building_purpose],
30
  }
31
-
32
  model = load_model()
33
- prediction = model.predict(pd.DataFrame.from_dict(new_project))
34
- return prediction[0].tolist()
35
 
36
- # Gradio 인터페이스 생성
37
- iface = gr.Interface(
38
- fn=predict,
39
- inputs=[
40
- gr.Textbox(label="구조", default="철근콘크리트조"),
41
- gr.Number(label="지하층수", default=1),
42
- gr.Number(label="지상층수", default=1),
43
- gr.Number(label="연면적", default=300),
44
- gr.Number(label="대지면적", default=500),
45
- gr.Number(label="건축면적", default=120),
46
- gr.Number(label="조경면적", default=150),
47
- gr.Number(label="주차수", default=50),
48
- gr.Number(label="발주년", default=2023),
49
- gr.Number(label="발주월", default=9),
50
- gr.Number(label="공사기간", default=100),
51
- gr.Textbox(label="현장위치", default="경기도"),
52
- gr.Textbox(label="건축법상용도", default="업무시설"),
53
- ],
54
- outputs=[
55
- gr.Textbox(label="건축공사비"),
56
- gr.Textbox(label="기계공사비"),
57
- gr.Textbox(label="전기공사비"),
58
- gr.Textbox(label="통신공사비"),
59
- gr.Textbox(label="토목공사비"),
60
- gr.Textbox(label="조경공사비")
61
- ],
62
- title="HG 공사비 예측 서비스",
63
- description="프로젝트 개요를 기반으로 공사비를 예측합니다."
64
- )
 
 
 
 
 
 
 
 
65
 
66
- # Gradio 앱을 실행합니다.
67
- iface.launch()
 
9
  return loaded_pipeline
10
 
11
  # 예측 함수 정의
12
+ def predict_cost(구조, 지하층수, 지상층수, 주차수, 연면적, 대지면적, 건축면적, 조경면적, 발주년, 발주월, 공사기간, 현장위치, 건축법상용도):
 
 
 
13
  new_project = {
14
+ '구조': [구조],
15
+ '지하층수': [지하층수],
16
+ '지상층수': [지상층수],
17
+ '주차수': [주차수],
18
+ '연면적': [연면적],
19
+ '대지면적': [대지면적],
20
+ '건축면적': [건축면적],
21
+ '조경면적': [조경면적],
22
+ '발주년': [발주년],
23
+ '발주월': [발주월],
24
+ '공사기간': [공사기간],
25
+ '현장위치': [현장위치],
26
+ '건축법상용도': [건축법상용도],
27
  }
28
+
29
  model = load_model()
30
+ pred = model.predict(pd.DataFrame.from_dict(new_project))
31
+ return [f'{cost:,.0f}원' for cost in pred[0]]
32
 
33
+ with gr.Blocks() as demo:
34
+ gr.Markdown("HG 공사비 예측 모델")
35
+ with gr.Row():
36
+ 구조 = gr.Dropdown(label="구조", choices=['철근콘크리트조', ''], value='철근콘크리트조') # '...'부분에 다른 구조 타입 추가
37
+ with gr.Row():
38
+ 지하층수 = gr.Number(label="지하층수", value=1)
39
+ 지상층수 = gr.Number(label="지상층수", value=1)
40
+ 주차수 = gr.Number(label="주차대수", value=50)
41
+ with gr.Row():
42
+ 연면적 = gr.Number(label="연면적(m2)", value=300)
43
+ 대지면적 = gr.Number(label="대지면적(m2)", value=500)
44
+ 건축면적 = gr.Number(label="건축면적(m2)", value=120)
45
+ 조경면적 = gr.Number(label="조경면적(m2)", value=150)
46
+ with gr.Row():
47
+ 발주년 = gr.Number(label="발주년", value=2023)
48
+ 발주월 = gr.Number(label="발주월", value=9)
49
+ 공사기간 = gr.Number(label="공사기간(일)", value=100)
50
+ with gr.Row():
51
+ 현장위치 = gr.Dropdown(label="현장위치", choices=['경기도', ''], value='경기도') # '...'부분에 다른 현장 위치 추가
52
+ 건축법상용도 = gr.Dropdown(label="건축법상용도", choices=['업무시설', ''], value='업무시설') # '...'부분에 다른 건축법상용도 추가
53
+
54
+ btn = gr.Button("예측")
55
+
56
+ btn.click(
57
+ predict_cost,
58
+ inputs=[
59
+ 구조, 지하층수, 지상층수, 주차수, 연면적, 대지면적, 건축면적, 조경면적, 발주년, 발주월, 공사기간, 현장위치, 건축법상용도
60
+ ],
61
+ outputs=[
62
+ gr.Textbox(label="건축공사비"),
63
+ gr.Textbox(label="기계공사비"),
64
+ gr.Textbox(label="전기공사비"),
65
+ gr.Textbox(label="통신공사비"),
66
+ gr.Textbox(label="토목공사비"),
67
+ gr.Textbox(label="조경공사비")
68
+ ]
69
+ )
70
 
71
+ demo.launch()