blackshadow1 commited on
Commit
1fea0a1
·
verified ·
1 Parent(s): 512f08c

implemeted an Model , login free✅✅`

Browse files
Files changed (1) hide show
  1. app.py +29 -14
app.py CHANGED
@@ -1,10 +1,11 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load Hugging Face pipelines directly (no local storage required)
5
- ner_pipeline = pipeline("ner", model="blackshadow1/biobert-ner-model")
6
- sentiment_pipeline = pipeline("sentiment-analysis", model="blackshadow1/sentiment-model")
7
- summarization_pipeline = pipeline("summarization", model="blackshadow1/t5-summarization-model")
 
8
 
9
  # Function to process user input
10
  def ai_doctor_interaction(user_input, chat_history=[]):
@@ -20,10 +21,15 @@ def ai_doctor_interaction(user_input, chat_history=[]):
20
  summary = summarization_pipeline(user_input, max_length=50, min_length=10, do_sample=False)[0]['summary_text']
21
 
22
  # Generate AI Doctor response
 
 
 
 
23
  response = f"""
24
- **Entities Identified**: {', '.join(entities)}
25
- **Sentiment**: {sentiment}
26
- **Summary**: {summary}
 
27
  """
28
  chat_history.append(("You", user_input))
29
  chat_history.append(("AI Doctor", response))
@@ -31,17 +37,26 @@ def ai_doctor_interaction(user_input, chat_history=[]):
31
 
32
  # Gradio interface
33
  with gr.Blocks() as demo:
34
- gr.Markdown("<h1 style='text-align: center;'>AI Doctor Avatar</h1>")
35
- gr.Markdown("<p style='text-align: center;'>Interact with the AI Doctor to resolve your health-related queries.</p>")
36
 
37
  with gr.Row():
38
  with gr.Column(scale=1):
39
- gr.Video(value="https://app.aistudios.com/share/681356f694258c96c250d3d0", autoplay=True, loop=True, show_controls=False)
 
 
 
 
 
 
 
 
40
  with gr.Column(scale=2):
41
- chatbot = gr.Chatbot(label="AI Doctor Chat Interface")
42
- user_input = gr.Textbox(label="Your Message", placeholder="Type your question here...")
43
- submit_button = gr.Button("Send")
44
- clear_button = gr.Button("Clear Chat")
 
45
 
46
  # Define interactions
47
  submit_button.click(ai_doctor_interaction, inputs=[user_input, chatbot], outputs=[chatbot, chatbot])
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load Hugging Face pipelines directly
5
+ ner_pipeline = pipeline("ner", model="dslim/bert-base-NER") # Named Entity Recognition
6
+ sentiment_pipeline = pipeline("sentiment-analysis") # Sentiment Analysis
7
+ summarization_pipeline = pipeline("summarization", model="facebook/bart-large-cnn") # Summarization
8
+ conversation_pipeline = pipeline("conversational", model="microsoft/DialoGPT-medium") # Conversational AI
9
 
10
  # Function to process user input
11
  def ai_doctor_interaction(user_input, chat_history=[]):
 
21
  summary = summarization_pipeline(user_input, max_length=50, min_length=10, do_sample=False)[0]['summary_text']
22
 
23
  # Generate AI Doctor response
24
+ conversation = conversation_pipeline(user_input)
25
+ ai_response = conversation.generated_responses[-1]
26
+
27
+ # Combine results into a response
28
  response = f"""
29
+ **Entities Identified**: {', '.join(entities)}
30
+ **Sentiment**: {sentiment}
31
+ **Summary**: {summary}
32
+ **AI Doctor Response**: {ai_response}
33
  """
34
  chat_history.append(("You", user_input))
35
  chat_history.append(("AI Doctor", response))
 
37
 
38
  # Gradio interface
39
  with gr.Blocks() as demo:
40
+ gr.Markdown("<h1 style='text-align: center; color: #4CAF50;'>AI Doctor Avatar</h1>")
41
+ gr.Markdown("<p style='text-align: center; font-size: 1.2em;'>Interact with the AI Doctor to resolve your health-related queries.</p>")
42
 
43
  with gr.Row():
44
  with gr.Column(scale=1):
45
+ gr.Markdown("<h3 style='text-align: center;'>AI Doctor Avatar</h3>")
46
+ gr.HTML("""
47
+ <div style="position: relative; overflow: hidden; aspect-ratio: 1920/1080">
48
+ <iframe src="https://ff-resource.aistudios.com/2025-05-01/6813589d929f360ef7c28ecd.completed.mp4"
49
+ loading="lazy" title="AI Doctor Avatar" allow="encrypted-media; fullscreen;"
50
+ style="position: absolute; width: 100%; height: 100%; top: 0; left: 0; border: none; padding: 0; margin: 0; overflow:hidden;">
51
+ </iframe>
52
+ </div>
53
+ """)
54
  with gr.Column(scale=2):
55
+ chatbot = gr.Chatbot(label="AI Doctor Chat Interface", height=400)
56
+ user_input = gr.Textbox(label="Your Message", placeholder="Type your question here...", lines=2)
57
+ with gr.Row():
58
+ submit_button = gr.Button("Send", variant="primary")
59
+ clear_button = gr.Button("Clear Chat", variant="secondary")
60
 
61
  # Define interactions
62
  submit_button.click(ai_doctor_interaction, inputs=[user_input, chatbot], outputs=[chatbot, chatbot])