OmParkashPandeY commited on
Commit
8f8f0e3
1 Parent(s): 77fb0a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -35
app.py CHANGED
@@ -1,38 +1,8 @@
1
- import os
2
- from dotenv import load_dotenv, find_dotenv
3
- _ = load_dotenv(find_dotenv())
4
- hf_api_key = os.environ['HF_API_KEY']
5
 
6
- API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
7
 
 
 
8
 
9
- # Helper function
10
- import requests, json
11
-
12
- #Summarization endpoint
13
- def get_completion(inputs, parameters=None,ENDPOINT_URL=API_URL):
14
- headers = {
15
- "Authorization": f"Bearer {hf_api_key}",
16
- "Content-Type": "application/json"
17
- }
18
- data = { "inputs": inputs }
19
- if parameters is not None:
20
- data.update({"parameters": parameters})
21
- response = requests.request("POST",ENDPOINT_URL, headers=headers,data=json.dumps(data))
22
- return json.loads(response.content.decode("utf-8"))
23
-
24
-
25
- from transformers import pipeline
26
-
27
- model_end_point = "facebook/bart-large-cnn"
28
- get_completion = pipeline("summarization", model=model_end_point)
29
-
30
-
31
- import gradio as gr
32
- def summarize(input):
33
- output = get_completion(input)
34
- return output[0]['summary_text']
35
-
36
- gr.close_all()
37
- demo = gr.Interface(fn=summarize, inputs="text", outputs="text")
38
- demo.launch(share=True)
 
1
+ from src.controllers.text_summarize_controller import loadGUI
 
 
 
2
 
 
3
 
4
+ def main():
5
+ loadGUI()
6
 
7
+ if __name__ == '__main__':
8
+ main()