springwater commited on
Commit
b7f4bba
β€’
1 Parent(s): acc7635

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # μžκΈ°μ†Œκ°œμ„œ 생성 λͺ¨λΈ μ΄ˆκΈ°ν™”
5
+ generator = pipeline('text-generation', model='distilbart-cnn-12-6')
6
+
7
+ def generate_self_introduction(job, strength, weakness, major, experience):
8
+ # μž…λ ₯ ν‚€μ›Œλ“œ 처리
9
+ job = job.strip()
10
+ strength = [s.strip() for s in strength.split(',')]
11
+ weakness = [w.strip() for w in weakness.split(',')]
12
+ major = major.strip()
13
+ experience = [e.strip() for e in experience.split(',')]
14
+
15
+ # μžκΈ°μ†Œκ°œμ„œ 생성
16
+ intro = f'μ•ˆλ…•ν•˜μ„Έμš”, {job} 직무에 μ§€μ›ν•˜λŠ” [이름]μž…λ‹ˆλ‹€.\n'
17
+ intro += f'μ €λŠ” {major} 전곡 μΆœμ‹ μœΌλ‘œ {experience[0]} κ²½ν—˜μ΄ μžˆμŠ΅λ‹ˆλ‹€.\n'
18
+ intro += f'μ €μ˜ 성격 μž₯점은 {", ".join(strength)}μž…λ‹ˆλ‹€.\n'
19
+ intro += f'μ €μ˜ 성격 단점은 {", ".join(weakness)}μž…λ‹ˆλ‹€.\n'
20
+ intro += generator(job, max_length=5000, num_return_sequences=1)[0]['generated_text']
21
+
22
+ return intro
23
+
24
+ # Gradio μΈν„°νŽ˜μ΄μŠ€ 생성
25
+ iface = gr.Interface(
26
+ fn=generate_self_introduction,
27
+ inputs=[
28
+ gr.Textbox(label='μ·¨μ—…ν•  직무 이름'),
29
+ gr.Textbox(label='λ‚˜μ˜ 성격 μž₯점 (콀마둜 ꡬ뢄)'),
30
+ gr.Textbox(label='λ‚˜μ˜ 성격 단점 (콀마둜 ꡬ뢄)'),
31
+ gr.Textbox(label='전곡'),
32
+ gr.Textbox(label='λŒ€μ™Έν™œλ™ κ²½ν—˜ (콀마둜 ꡬ뢄)'),
33
+ ],
34
+ outputs=gr.Textbox(label='μžκΈ°μ†Œκ°œμ„œ'),
35
+ title='μžκΈ°μ†Œκ°œμ„œ 생성 μ„œλΉ„μŠ€',
36
+ description='μ·¨μ—…ν•  직무 이름, λ‚˜μ˜ 성격 μž₯점, λ‚˜μ˜ 성격 단점, 전곡, λŒ€μ™Έν™œλ™ κ²½ν—˜μ„ μž…λ ₯ν•˜μ—¬ μžκΈ°μ†Œκ°œμ„œλ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.'
37
+ )
38
+
39
+ # Gradio μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ‹€ν–‰
40
+ iface.launch()