fix
Browse files- app.py +2 -11
- requirements.txt +2 -4
app.py
CHANGED
@@ -41,22 +41,13 @@ image_generator = StableDiffusionPipeline.from_pretrained(
|
|
41 |
lora_weights = "lacos03/std-1.5-lora-midjourney-1.0"
|
42 |
image_generator.load_lora_weights(lora_weights)
|
43 |
|
44 |
-
|
45 |
-
NUM_BEAMS = 10
|
46 |
-
NO_REPEAT_NGRAM_SIZE = 3
|
47 |
-
LENGTH_PENALTY = 1.0
|
48 |
-
MIN_NEW_TOKENS = 10
|
49 |
-
MAX_NEW_TOKENS = 62
|
50 |
# === Hàm xử lý ===
|
51 |
def summarize_article(article_text):
|
52 |
"""Tóm tắt bài viết và tạo prompt refinement"""
|
53 |
if not article_text.strip():
|
54 |
return "[Empty]", "[Empty]"
|
55 |
-
summary = summarizer(article_text,
|
56 |
-
no_repeat_ngram_size=NO_REPEAT_NGRAM_SIZE,
|
57 |
-
length_penalty=LENGTH_PENALTY,
|
58 |
-
min_new_tokens=MIN_NEW_TOKENS,
|
59 |
-
max_new_tokens=MAX_NEW_TOKENS, do_sample=False)[0]["summary_text"]
|
60 |
title = summary.split(".")[0] + "."
|
61 |
# Prompt refinement
|
62 |
input_ids = promptist_tokenizer(title.strip() + " Rephrase:", return_tensors="pt").input_ids.to(device)
|
|
|
41 |
lora_weights = "lacos03/std-1.5-lora-midjourney-1.0"
|
42 |
image_generator.load_lora_weights(lora_weights)
|
43 |
|
44 |
+
|
|
|
|
|
|
|
|
|
|
|
45 |
# === Hàm xử lý ===
|
46 |
def summarize_article(article_text):
|
47 |
"""Tóm tắt bài viết và tạo prompt refinement"""
|
48 |
if not article_text.strip():
|
49 |
return "[Empty]", "[Empty]"
|
50 |
+
summary = summarizer(article_text, max_length=100, min_length=30, do_sample=False)[0]["summary_text"]
|
|
|
|
|
|
|
|
|
51 |
title = summary.split(".")[0] + "."
|
52 |
# Prompt refinement
|
53 |
input_ids = promptist_tokenizer(title.strip() + " Rephrase:", return_tensors="pt").input_ids.to(device)
|
requirements.txt
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
gradio==3.50.2
|
2 |
transformers==4.42.4
|
3 |
-
torch==2.0.1
|
4 |
-
torchvision==0.15.2+cu118
|
5 |
-
torchaudio==2.0.2+cu118
|
6 |
diffusers==0.29.2
|
7 |
pillow==9.5.0
|
8 |
safetensors>=0.4.1
|
9 |
huggingface_hub==0.23.4
|
10 |
-
peft==0.12.0
|
|
|
1 |
gradio==3.50.2
|
2 |
transformers==4.42.4
|
3 |
+
torch==2.0.1
|
|
|
|
|
4 |
diffusers==0.29.2
|
5 |
pillow==9.5.0
|
6 |
safetensors>=0.4.1
|
7 |
huggingface_hub==0.23.4
|
8 |
+
peft==0.12.0
|