BabakBagheriGisour commited on
Commit
b76236a
·
verified ·
1 Parent(s): e65927e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -47,30 +47,30 @@ if uploaded_file:
47
  final_summary = ""
48
 
49
  for idx, line in enumerate(lines):
50
- if len(line.strip()) == 0: # عبور از خطوط خالی
51
- continue
52
-
53
- # تبدیل خط به توکن
54
- input_ids = tokenizer.encode(line, return_tensors="pt", truncation=True, max_length=1024)
55
-
56
- # تولید خلاصه برای هر خط
57
- try:
58
- summary_ids = model.generate(
59
- input_ids=input_ids,
60
- num_beams=2,
61
- max_length=50, # حداکثر طول خلاصه
62
- min_length=10 # حداقل طول خلاصه، در صورت نیاز قابل تنظیم است
63
- )
64
- decoded_summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
65
- final_summary += decoded_summary + " "
66
- except Exception as e:
67
- st.warning(f"Fehler bei Zeile {idx + 1}: {e}")
68
-
69
- # نمایش خلاصه فعلی
70
- st.write(f"**Zeile {idx + 1}:** {decoded_summary}")
71
-
72
- # به‌روزرسانی نوار پیشرفت
73
- progress_bar.progress((idx + 1) / num_lines)
74
 
75
 
76
  # نمایش خلاصه نهایی
 
47
  final_summary = ""
48
 
49
  for idx, line in enumerate(lines):
50
+ if len(line.strip()) == 0: # عبور از خطوط خالی
51
+ continue
52
+
53
+ # تبدیل خط به توکن
54
+ input_ids = tokenizer.encode(line, return_tensors="pt", truncation=True, max_length=1024)
55
+
56
+ # تولید خلاصه برای هر خط
57
+ try:
58
+ summary_ids = model.generate(
59
+ input_ids=input_ids,
60
+ num_beams=2,
61
+ max_length=50, # حداکثر طول خلاصه
62
+ min_length=10 # حداقل طول خلاصه، در صورت نیاز قابل تنظیم است
63
+ )
64
+ decoded_summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
65
+ final_summary += decoded_summary + " "
66
+ except Exception as e:
67
+ st.warning(f"Fehler bei Zeile {idx + 1}: {e}")
68
+
69
+ # نمایش خلاصه فعلی
70
+ st.write(f"**Zeile {idx + 1}:** {decoded_summary}")
71
+
72
+ # به‌روزرسانی نوار پیشرفت
73
+ progress_bar.progress((idx + 1) / num_lines)
74
 
75
 
76
  # نمایش خلاصه نهایی