Soltane777 commited on
Commit
3cc249d
·
verified ·
1 Parent(s): 26a6339

Delete app

Browse files
Files changed (4) hide show
  1. app/main.py +0 -8
  2. app/models.py +0 -40
  3. app/templates/index.html +0 -26
  4. app/utils.py +0 -0
app/main.py DELETED
@@ -1,8 +0,0 @@
1
- from fastapi import FastAPI
2
- from models import summarize_text, analyze_image, answer_question, generate_visualization, translate_document
3
-
4
- app = FastAPI()
5
-
6
- @app.get("/")
7
- def read_root():
8
- return {"message": "Hello, World!"}
 
 
 
 
 
 
 
 
 
app/models.py DELETED
@@ -1,40 +0,0 @@
1
- from transformers import pipeline
2
-
3
- # وظيفة تلخيص النصوص
4
- def summarize_text(document: str):
5
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
- summary = summarizer(document, max_length=130, min_length=30, do_sample=False)
7
- return summary[0]['summary_text']
8
-
9
- # وظيفة تفسير الصور
10
- def analyze_image(image):
11
- image_analyzer = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
12
- result = image_analyzer(image)
13
- return result[0]['generated_text']
14
-
15
- # وظيفة الإجابة على الأسئلة
16
- def answer_question(question: str, document: str):
17
- qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
18
- result = qa_pipeline(question=question, context=document)
19
- return result['answer']
20
-
21
- # وظيفة إنشاء تصورات بيانات
22
- def generate_visualization(data, request):
23
- import pandas as pd
24
- import matplotlib.pyplot as plt
25
- import seaborn as sns
26
-
27
- df = pd.read_excel(data)
28
- # تنفيذ الطلب (مثال: رسم مخطط)
29
- if "bar" in request:
30
- plt.bar(df['column_name'], df['values'])
31
- elif "line" in request:
32
- plt.plot(df['column_name'], df['values'])
33
- plt.savefig("visualization.png")
34
- return "visualization.png"
35
-
36
- # وظيفة ترجمة المستندات
37
- def translate_document(document, target_language):
38
- translator = pipeline("translation", model=f"Helsinki-NLP/opus-mt-{target_language}")
39
- translation = translator(document)
40
- return translation[0]['translation_text']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/templates/index.html DELETED
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>AI Web App</title>
5
- </head>
6
- <body>
7
- <h1>AI-Powered Web Application</h1>
8
- <form action="/upload/" method="post" enctype="multipart/form-data">
9
- <input type="file" name="file">
10
- <button type="submit">Upload</button>
11
- </form>
12
- <form action="/summarize/" method="post">
13
- <textarea name="document" placeholder="Enter document text"></textarea>
14
- <button type="submit">Summarize</button>
15
- </form>
16
- <form action="/analyze-image/" method="post" enctype="multipart/form-data">
17
- <input type="file" name="image">
18
- <button type="submit">Analyze Image</button>
19
- </form>
20
- <form action="/answer/" method="post">
21
- <textarea name="document" placeholder="Enter document text"></textarea>
22
- <input type="text" name="question" placeholder="Enter your question">
23
- <button type="submit">Get Answer</button>
24
- </form>
25
- </body>
26
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/utils.py DELETED
File without changes