Update README.md
Browse files
README.md
CHANGED
|
@@ -1,87 +1,87 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
- en
|
| 6 |
base_model:
|
| 7 |
- Qwen/Qwen2-VL-7B-Instruct
|
| 8 |
-
pipeline_tag:
|
| 9 |
---
|
| 10 |
|
| 11 |
-
# Qwen2-VL-
|
| 12 |
|
| 13 |
-
##
|
| 14 |
|
| 15 |
-
Qwen2-VL-
|
| 16 |
|
| 17 |
-
###
|
| 18 |
|
| 19 |
-
* **
|
| 20 |
-
* **
|
| 21 |
-
* **
|
| 22 |
-
* **
|
| 23 |
|
| 24 |
-
**
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
`pip
|
| 31 |
|
| 32 |
-
##
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
-
model_id = "Ertugrul/Qwen2-VL-
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
)
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
{
|
| 48 |
-
|
| 49 |
-
|
| 50 |
{
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
}
|
| 56 |
]
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
#
|
| 63 |
-
#
|
| 64 |
|
| 65 |
-
text_prompt = processor.apply_chat_template(
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
)
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
]
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
|
| 87 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
Bibliothek_name: Transformatoren
|
| 3 |
+
Lizenz: Apache-2.0
|
| 4 |
+
Kratze:
|
| 5 |
- en
|
| 6 |
base_model:
|
| 7 |
- Qwen/Qwen2-VL-7B-Instruct
|
| 8 |
+
pipeline_tag: Bild-zu-text
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Qwen2-VL-7 B-Captioner-Entspannt
|
| 12 |
|
| 13 |
+
## Einleitung
|
| 14 |
|
| 15 |
+
Qwen2-VL-7 B-Captioner-Entspannte ist eine weisungsgestimmte Version von [Qwen2-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct), ein fortschrittliches multimodales Großsprachenmodell. Diese fein abgestimmte Version basiert auf einem handkuratieren Datensatz für Text-zu-Bild-Modelle und bietet deutlich detailliert Beschreibungen gebebener Bilder.
|
| 16 |
|
| 17 |
+
### Hauptmerkmale:
|
| 18 |
|
| 19 |
+
* **Erweitertes Detail:** Produkte umfassendere und differenzierte Bildbeschreibungen.
|
| 20 |
+
* **Entspanntes Einschränkungen:** Bietet im Verein zum Basismodell weniger restriktive Bildbeschreibungen.
|
| 21 |
+
* **Ausgabe naturlicher Sprache:** Beschreibt verschiedene Motive im Bild und gibt gleichzeit ihre Standorte in naturlicher Sprache an.
|
| 22 |
+
* **Optimiert für die Bilderzeugung:** Produzierte Bildunterschriften in Formaten, die mit modernsten Text-zu-Bild-Generierungsmodelle kompatibel sind.
|
| 23 |
|
| 24 |
+
**Anmerkung:** Dieses fin abgestimmte Modell ist für die Erstellung von Text-zu-Bild-Datensätzen optimiert. Infolgedessen kann die Lehrung bei anderen Aufgeben (z. B. ~10% Abnahme bei mmmu_val) im Verein zum Originalmodell geringer sein.
|
| 25 |
|
| 26 |
+
## Anfordungen
|
| 27 |
|
| 28 |
+
Wenn Sie auf Fehler stoßen wie `KeyError: 'qwen2_vl'` Oder `ImportError: kann Name 'Qwen2VLForConditionalGeneration' nicht aus 'Transformers' importieren`, Versuchen Sie, die neueste Version der Transformatorenbibliothek aus der Quelle zu installieren:
|
| 29 |
|
| 30 |
+
`pip installieren git+https://github.com/huggingface/transformers`
|
| 31 |
|
| 32 |
+
## Schnellstart
|
| 33 |
+
`Python
|
| 34 |
+
Von PIL-Import Bild
|
| 35 |
+
Von Transformatoren importieren Qwen2VLForConditionalGeneration, AutoProcessor
|
| 36 |
+
Von Transformatoren BitsAndBytesConfig importieren
|
| 37 |
+
Einfuhrbrenner
|
| 38 |
|
| 39 |
+
model_id = "Ertugrul/Qwen2-VL-7 B-Captioner-Relaxed"
|
| 40 |
|
| 41 |
+
Modell = Qwen2VLForConditionalGeneration.from_pretrained (
|
| 42 |
+
model_id, torch_dtyp=torch.bfloat16, device_map="auto"
|
| 43 |
)
|
| 44 |
+
Prozessor = AutoProcessor.from_pretrained (model_id)
|
| 45 |
|
| 46 |
+
Gesprüch = [
|
| 47 |
{
|
| 48 |
+
"Rolle": "Benutzer",
|
| 49 |
+
"inhalt": [
|
| 50 |
{
|
| 51 |
+
"type": "Bild",
|
| 52 |
+
},
|
| 53 |
+
{"type": "text", "text": "Beschreibe dieses Bild"},
|
| 54 |
+
],
|
| 55 |
}
|
| 56 |
]
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
+
Bild = Image.open (r "PATH_TO_YOUR_IMAGE")
|
| 61 |
|
| 62 |
+
# Sie können die Größe des Bildes hier Ändern, wenn es nicht zu vram passt, oder Modellmaximalgrößen festlegen.
|
| 63 |
+
# Bild = Bild.resize ((1024, 1024)) # so
|
| 64 |
|
| 65 |
+
text_prompt = processor.apply_chat_template (Gespräch, add_generation_prompt=True)
|
| 66 |
|
| 67 |
+
Eingänge = Prozessor (
|
| 68 |
+
text=[text_prompt], „images=[Bild], udding=True, return_tensors="pt"
|
| 69 |
)
|
| 70 |
+
Eingänge = Eingänge.to ("cuda")
|
| 71 |
|
| 72 |
+
mit Fackel.no_grad ():
|
| 73 |
+
mit torch.autocast (device_type=" cuda", dtype=torch.bfloat16):
|
| 74 |
+
output_ids = model.generate (**inputs, max_new_tokens=384, do_sample=True, temperatur=0.7, use_cache=True, top_k=50)
|
| 75 |
|
| 76 |
|
| 77 |
+
generierte_ids = [
|
| 78 |
+
Ausgabe_ids[len (input_ids):]
|
| 79 |
+
Für input_ids, output_ids in zip (inputs.input_ids, output_ids)
|
| 80 |
]
|
| 81 |
+
Ausgabe_text = processor.batch_decode (
|
| 82 |
+
generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
|
| 83 |
+
[0]
|
| 84 |
+
Ausdrucken (output_text)
|
| 85 |
+
`
|
| 86 |
|
| 87 |
+
Ausführliche Optionen finden Sie in der [Qwen2-VL-7B-Instruct] (https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct) Dokumentation.
|