medmekk HF Staff commited on
Commit
1022b16
·
verified ·
1 Parent(s): 82f646b

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def process_text(text):
4
+ """
5
+ Simple function that processes text:
6
+ - Converts to uppercase
7
+ - Counts words
8
+ - Returns both results
9
+ """
10
+ if not text:
11
+ return "Please enter some text!", 0
12
+
13
+ uppercase_text = text.upper()
14
+ word_count = len(text.split())
15
+
16
+ return uppercase_text, word_count
17
+
18
+ # Create the Gradio interface
19
+ demo = gr.Interface(
20
+ fn=process_text,
21
+ inputs=[
22
+ gr.Textbox(
23
+ label="Enter your text",
24
+ placeholder="Type something here...",
25
+ lines=3
26
+ )
27
+ ],
28
+ outputs=[
29
+ gr.Textbox(label="Uppercase Text", lines=3),
30
+ gr.Number(label="Word Count")
31
+ ],
32
+ title="📝 Text Processor",
33
+ description="Enter some text and I'll convert it to uppercase and count the words!",
34
+ examples=[
35
+ ["Hello world!"],
36
+ ["Gradio makes machine learning demos easy!"],
37
+ ["This is a sample text with multiple words to demonstrate the word counting feature."]
38
+ ],
39
+ theme=gr.themes.Soft()
40
+ )
41
+
42
+ if __name__ == "__main__":
43
+ demo.launch()