Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Hugging Face λͺ¨λΈ μ μ₯μμμ λͺ¨λΈμ λ€μ΄λ‘λνμ¬ μ΄κΈ°ν | |
generator = pipeline('text-generation', model='facebook/bart-base') | |
def generate_self_introduction(job, strength, weakness, major, experience): | |
# μ λ ₯ ν€μλ μ²λ¦¬ | |
job = job.strip() | |
strength = [s.strip() for s in strength.split(',')] | |
weakness = [w.strip() for w in weakness.split(',')] | |
major = major.strip() | |
experience = [e.strip() for e in experience.split(',')] | |
# μκΈ°μκ°μ μμ± | |
intro = f'μλ νμΈμ, {job} μ§λ¬΄μ μ§μνλ [μ΄λ¦]μ λλ€.\n' | |
intro += f'μ λ {major} μ 곡 μΆμ μΌλ‘ {experience[0]} κ²½νμ΄ μμ΅λλ€.\n' | |
intro += f'μ μ μ±κ²© μ₯μ μ {", ".join(strength)}μ λλ€.\n' | |
intro += f'μ μ μ±κ²© λ¨μ μ {", ".join(weakness)}μ λλ€.\n' | |
intro += generator(job, max_length=1024, num_return_sequences=1)[0]['generated_text'][:500] # μ΅λ κΈΈμ΄λ₯Ό 1024λ‘ μ ννκ³ , 500μκΉμ§λ§ μΆλ ₯ | |
return intro | |
# Gradio μΈν°νμ΄μ€ μμ± | |
iface = gr.Interface( | |
fn=generate_self_introduction, | |
inputs=[ | |
gr.Textbox(label='μ·¨μ ν μ§λ¬΄ μ΄λ¦'), | |
gr.Textbox(label='λμ μ±κ²© μ₯μ (μ½€λ§λ‘ ꡬλΆ)'), | |
gr.Textbox(label='λμ μ±κ²© λ¨μ (μ½€λ§λ‘ ꡬλΆ)'), | |
gr.Textbox(label='μ 곡'), | |
gr.Textbox(label='λμΈνλ κ²½ν (μ½€λ§λ‘ ꡬλΆ)'), | |
], | |
outputs=gr.Textbox(label='μκΈ°μκ°μ'), | |
title='μκΈ°μκ°μ μμ± μλΉμ€', | |
description='μ·¨μ ν μ§λ¬΄ μ΄λ¦, λμ μ±κ²© μ₯μ , λμ μ±κ²© λ¨μ , μ 곡, λμΈνλ κ²½νμ μ λ ₯νμ¬ μκΈ°μκ°μλ₯Ό μμ±ν©λλ€.' | |
) | |
# Gradio μ ν리μΌμ΄μ μ€ν | |
iface.launch() |