Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,6 @@ import docx
|
|
9 |
from arabert.preprocess import ArabertPreprocessor
|
10 |
import gradio as gr
|
11 |
|
12 |
-
# تعيين التوكن الخاص بـ OpenAI
|
13 |
-
openai.api_key = "sk-proj-62TDbO5KABSdkZaFPPD4T3BlbkFJkhqOYpHhL6OucTzNdWSU"
|
14 |
-
|
15 |
# التحقق من توفر GPU واستخدامه
|
16 |
device = 0 if torch.cuda.is_available() else -1
|
17 |
|
@@ -206,36 +203,26 @@ def analyze_files(input_files, output_directory, tokenizer, max_length):
|
|
206 |
return results
|
207 |
|
208 |
# تحديد المسارات
|
209 |
-
input_directory = "/Volumes/CLOCKWORK T/clockworkspace/first pro/in"
|
210 |
output_directory_950 = "/Volumes/CLOCKWORK T/clockworkspace/first pro/1000"
|
211 |
-
input_directory_950 = "/Volumes/CLOCKWORK T/clockworkspace/first pro/1000"
|
212 |
output_directory_950_out = "/Volumes/CLOCKWORK T/clockworkspace/first pro/out/1000"
|
213 |
|
214 |
# التأكد من وجود المسارات
|
215 |
os.makedirs(output_directory_950, exist_ok=True)
|
216 |
os.makedirs(output_directory_950_out, exist_ok=True)
|
217 |
|
218 |
-
# معالجة الملفات وتقسيمها
|
219 |
-
process_files(input_directory, output_directory_950)
|
220 |
-
|
221 |
-
# تحليل الملفات المقسمة إلى 950 توكنز
|
222 |
-
analyze_files(input_directory_950, output_directory_950_out, gpt2_tokenizer, 950)
|
223 |
-
|
224 |
-
print("تمت معالجة الملفات وتحليلها بنجاح.")
|
225 |
-
|
226 |
# تعريف واجهة Gradio
|
227 |
def analyze_and_complete(input_files):
|
228 |
# معالجة الملفات وتقسيمها
|
229 |
process_files(input_files, output_directory_950)
|
230 |
|
231 |
# تحليل الملفات المقسمة إلى 950 توكنز
|
232 |
-
results = analyze_files(
|
233 |
|
234 |
return results
|
235 |
|
236 |
interface = gr.Interface(
|
237 |
fn=analyze_and_complete,
|
238 |
-
inputs=gr.File(file_count="multiple", type="
|
239 |
outputs="json",
|
240 |
title="Movie Script Analyzer and Completer",
|
241 |
description="Upload text, PDF, or DOCX files to analyze and complete the movie script."
|
|
|
9 |
from arabert.preprocess import ArabertPreprocessor
|
10 |
import gradio as gr
|
11 |
|
|
|
|
|
|
|
12 |
# التحقق من توفر GPU واستخدامه
|
13 |
device = 0 if torch.cuda.is_available() else -1
|
14 |
|
|
|
203 |
return results
|
204 |
|
205 |
# تحديد المسارات
|
|
|
206 |
output_directory_950 = "/Volumes/CLOCKWORK T/clockworkspace/first pro/1000"
|
|
|
207 |
output_directory_950_out = "/Volumes/CLOCKWORK T/clockworkspace/first pro/out/1000"
|
208 |
|
209 |
# التأكد من وجود المسارات
|
210 |
os.makedirs(output_directory_950, exist_ok=True)
|
211 |
os.makedirs(output_directory_950_out, exist_ok=True)
|
212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
# تعريف واجهة Gradio
|
214 |
def analyze_and_complete(input_files):
|
215 |
# معالجة الملفات وتقسيمها
|
216 |
process_files(input_files, output_directory_950)
|
217 |
|
218 |
# تحليل الملفات المقسمة إلى 950 توكنز
|
219 |
+
results = analyze_files(input_files, output_directory_950_out, gpt2_tokenizer, 950)
|
220 |
|
221 |
return results
|
222 |
|
223 |
interface = gr.Interface(
|
224 |
fn=analyze_and_complete,
|
225 |
+
inputs=gr.File(file_count="multiple", type="filepath"),
|
226 |
outputs="json",
|
227 |
title="Movie Script Analyzer and Completer",
|
228 |
description="Upload text, PDF, or DOCX files to analyze and complete the movie script."
|