matsuap commited on
Commit
74c8ddc
·
1 Parent(s): 3a54f0c

README.mdのタイトル、絵文字、色の設定を更新し、ライセンス情報を追加しました。

Browse files
Files changed (3) hide show
  1. README.md +5 -4
  2. app.py +61 -0
  3. requirements.txt +7 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: Heron Demo
3
- emoji:
4
- colorFrom: pink
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 5.29.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Heron NVILA Lite
3
+ emoji: 🏆
4
+ colorFrom: blue
5
+ colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 5.29.0
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoConfig, AutoModel
2
+ import gradio as gr
3
+ import spaces
4
+
5
+ model_path = "turing-motors/Heron-NVILA-Lite-15B"
6
+
7
+ # or directly from_pretrained
8
+ model = AutoModel.from_pretrained(model_path, trust_remote_code=True, device_map="auto")
9
+
10
+ # examples generate using generation_config
11
+ from PIL import Image
12
+ import requests
13
+ from transformers import GenerationConfig
14
+ generation_config = {
15
+ "max_new_tokens": 2048,
16
+ "temperature": 0.5,
17
+ "do_sample": True,
18
+ }
19
+ generation_config = GenerationConfig(**generation_config)
20
+
21
+ DESCRIPTION = '''
22
+ <div>
23
+ <h1 style="text-align: center;">非公式Heron-NVILA-Lite-15B</h1>
24
+ <p>Heron-NVILA-Lite-15Bの非公式デモだよ。 <a href="https://huggingface.co/turing-motors/Heron-NVILA-Lite-15B"><b>turing-motors/Heron-NVILA-Lite-15B</b></a>.</p>
25
+ </div>
26
+ '''
27
+
28
+ @spaces.GPU()
29
+ def infer(image):
30
+ response = model.generate_content(
31
+ [image, "画像を可能な限り詳細に説明してください。"],
32
+ generation_config=generation_config
33
+ )
34
+
35
+ return response
36
+
37
+ css = """
38
+ h1 {
39
+ text-align: center;
40
+ display: block;
41
+ }
42
+ #col-container {
43
+ margin: 0 auto;
44
+ max-width: 520px;
45
+ }
46
+ """
47
+
48
+ with gr.Blocks(fill_height=True, css=css) as demo:
49
+ with gr.Column(elem_id="col-container"):
50
+ gr.Markdown(DESCRIPTION)
51
+ image_input=gr.Image(type="pil", label="画像をアップロード")
52
+ run_button = gr.Button("画像の説明文を生成する", scale=0)
53
+ text_output=gr.Textbox(label="生成されたテキスト")
54
+ run_button.click(
55
+ fn = infer,
56
+ inputs = image_input,
57
+ outputs = text_output,
58
+ )
59
+
60
+ if __name__ == "__main__":
61
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ transformers==4.45.0
2
+ accelerate
3
+ opencv-python
4
+ torchvision
5
+ einops
6
+ pillow
7
+ git+https://github.com/bfshi/scaling_on_scales.git