Vivek7311 commited on
Commit
f5558c0
·
verified ·
1 Parent(s): d90f6d8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Model aani files HF space chya main folder madhech ahet mhanun path "./" thevlay
5
+ model_path = "./"
6
+
7
+ print("Model load hot ahe, kripaya thamba...")
8
+
9
+ # Text-generation saathi pipeline banavli ahe
10
+ try:
11
+ # Jar tujha model text-classification kiva dusra asel tar "text-generation" badlu shaktos
12
+ pipe = pipeline("text-generation", model=model_path)
13
+ except Exception as e:
14
+ print(f"Model load kartana error aala: {e}")
15
+
16
+ def generate_text(prompt):
17
+ if not prompt:
18
+ return "Kripaya kahi tari text type kara."
19
+ try:
20
+ # Prompt model la deun output kadhne (max_length tu tujhya hishobane badlu shaktos)
21
+ output = pipe(prompt, max_length=150, do_sample=True, temperature=0.7)
22
+ return output[0]['generated_text']
23
+ except Exception as e:
24
+ return f"Kahitari chukla ahe (Error): {str(e)}"
25
+
26
+ # Gradio cha UI (User Interface)
27
+ demo = gr.Interface(
28
+ fn=generate_text,
29
+ inputs=gr.Textbox(lines=4, placeholder="Tula je vicharaychay te ithe type kar..."),
30
+ outputs=gr.Textbox(label="AI Model che Uttar:"),
31
+ title="🤖 Majha Swatacha AI Model",
32
+ description="Ha majha custom text AI model ahe jo Hugging Face var deploy kela ahe. Type kara aani test kara!",
33
+ theme="default"
34
+ )
35
+
36
+ # App chalu karne
37
+ if __name__ == "__main__":
38
+ demo.launch()