File size: 1,345 Bytes
f5558c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
from transformers import pipeline

# Model aani files HF space chya main folder madhech ahet mhanun path "./" thevlay
model_path = "./" 

print("Model load hot ahe, kripaya thamba...")

# Text-generation saathi pipeline banavli ahe
try:
    # Jar tujha model text-classification kiva dusra asel tar "text-generation" badlu shaktos
    pipe = pipeline("text-generation", model=model_path)
except Exception as e:
    print(f"Model load kartana error aala: {e}")

def generate_text(prompt):
    if not prompt:
        return "Kripaya kahi tari text type kara."
    try:
        # Prompt model la deun output kadhne (max_length tu tujhya hishobane badlu shaktos)
        output = pipe(prompt, max_length=150, do_sample=True, temperature=0.7)
        return output[0]['generated_text']
    except Exception as e:
        return f"Kahitari chukla ahe (Error): {str(e)}"

# Gradio cha UI (User Interface)
demo = gr.Interface(
    fn=generate_text,
    inputs=gr.Textbox(lines=4, placeholder="Tula je vicharaychay te ithe type kar..."),
    outputs=gr.Textbox(label="AI Model che Uttar:"),
    title="🤖 Majha Swatacha AI Model",
    description="Ha majha custom text AI model ahe jo Hugging Face var deploy kela ahe. Type kara aani test kara!",
    theme="default"
)

# App chalu karne
if __name__ == "__main__":
    demo.launch()