File size: 3,877 Bytes
f616a1a
b87996d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6667fb
b87996d
 
 
 
 
 
f616a1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MiniGPT-4 WebGPU</title>
<meta name="description" content="The original 2023 MiniGPT-4 (EVA ViT-G, Q-Former, Vicuna-7B v0) running on your own GPU in the browser. Nothing is uploaded.">
<link rel="icon" href="data:,">
<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
  <p id="line"><b><a href="https://github.com/Vision-CAIR/MiniGPT-4" target="_blank" rel="noopener">MiniGPT-4</a></b>, the original April 2023 model, running on <b>your GPU</b>:
    a vision encoder and a 4-bit Vicuna-7B, nothing uploaded. First use downloads about 5 GB, kept in your browser.</p>

  <label id="drop" for="file"><input id="file" type="file" accept="image/*"><span>Drop an image here, or choose one</span></label>
  <p id="examples-row">Or try: <span id="examples"></span></p>
  <img id="preview" alt="" hidden>

  <p id="status" role="status" aria-live="polite">Pick an image to begin.</p>
  <div id="bar"><i></i></div>

  <form id="ask" autocomplete="off">
    <label for="q" class="sr">Question about the image</label>
    <input id="q" type="text" maxlength="400" value="Describe this image in detail." disabled>
    <button id="go" type="submit" disabled>Ask</button>
    <button id="stop" type="button" hidden>Stop</button>
  </form>
  <p id="prompts"></p>
  <section id="log" aria-live="polite"></section>

  <details id="more">
    <summary>How it works, limits and credits</summary>
    <p><b>Model.</b> The original MiniGPT-4 (Vision-CAIR, KAUST): a frozen EVA ViT-G, a frozen BLIP-2 Q-Former and one trained linear projection feed 32 image tokens to Vicuna-7B v0. The vision part runs as an 8-bit ONNX graph on
      <a href="https://onnxruntime.ai/" target="_blank" rel="noopener">ONNX Runtime Web</a> (1.2 GB); the language model is a 4-bit GGUF (3.8 GB) on <a href="https://github.com/ngxson/wllama" target="_blank" rel="noopener">wllama</a> (llama.cpp WebAssembly + WebGPU).
      Weights: <a id="repo" target="_blank" rel="noopener">the model repo</a>. Sources: <a href="https://huggingface.co/spaces/Luminia/MiniGPT-4" target="_blank" rel="noopener">Luminia/MiniGPT-4</a>, whose CPU/GPU version this mirrors, <a href="https://huggingface.co/Vision-CAIR/vicuna-7b" target="_blank" rel="noopener">Vision-CAIR/vicuna-7b</a>.</p>
    <p><b>How the image gets in.</b> llama.cpp (and so wllama) cannot take raw embeddings, so the 32 image vectors are written into 32 reserved rows of the model's token-embedding table (the byte tokens &lt;0x80&gt;…&lt;0x9F&gt;) before the model is loaded, and the prompt carries those 32 token ids.
      A new image therefore reloads the language model from your browser's cache (some seconds); more questions about the same image do not. Text containing those rare byte tokens is not supported.</p>
    <p><b>Limits.</b> About 6 GB of free memory and a GPU with 4 GB+ of video memory are needed; without WebGPU it runs on the CPU, at under one word a second. This is a 2023 model: captions are often wrong in details, and it is uncensored, so it describes whatever you give it.
      Vicuna v0 is derived from LLaMA-1 (non-commercial research licence).</p>
    <p><b>If answers look wrong or refuse.</b> Add <code>?vgpu=0</code> (vision on the CPU), <code>?llmgpu=0</code> (language model on the CPU) or <code>?check=1</code> (compare the GPU and CPU image embeddings) to the address to find out which part misbehaves on your GPU. The original Python version is on the <a href="https://huggingface.co/spaces/WeReCooking/MiniGPT4-WebGPU/tree/python" target="_blank" rel="noopener"><code>python</code> branch</a>.</p>
    <p id="store"></p>
    <button id="wipe" type="button">Delete downloaded models</button>
  </details>
</main>
<script type="module" src="main.js"></script>
</body>
</html>