| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| model_path = "./" |
|
|
| print("Model load hot ahe, kripaya thamba...") |
|
|
| |
| try: |
| |
| 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: |
| |
| 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)}" |
|
|
| |
| 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" |
| ) |
|
|
| |
| if __name__ == "__main__": |
| demo.launch() |