TheHickman commited on
Commit
3917449
·
verified ·
1 Parent(s): 73e32b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -1,6 +1,12 @@
1
  import gradio as gr
2
  from openai import OpenAI
3
  import os
 
 
 
 
 
 
4
 
5
  client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
6
 
@@ -48,7 +54,7 @@ YOUR_WORK_HTML = """
48
  # ---- Hugging Face reference content ----
49
  HF_REFERENCE_HTML = """
50
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
51
- <img src="./HFImage.png" style="width:100%; border-radius:8px; margin-bottom:20px;" />
52
  <h1>Text Generation (Hugging Face Reference)</h1>
53
  <h1>About Text Generation</h1>
54
  <p>
 
1
  import gradio as gr
2
  from openai import OpenAI
3
  import os
4
+ import base64
5
+
6
+ with open("HFImage.png", "rb") as f:
7
+ encoded = base64.b64encode(f.read()).decode()
8
+
9
+ IMAGE_HTML = f'<img src="data:image/png;base64,{encoded}" style="width:100%; border-radius:8px; margin-bottom:20px;" />'
10
 
11
  client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
12
 
 
54
  # ---- Hugging Face reference content ----
55
  HF_REFERENCE_HTML = """
56
  <div id="hf-content" style="max-width: 800px; margin: auto; font-size: 16px; line-height: 1.6;">
57
+ {IMAGE_HTML}
58
  <h1>Text Generation (Hugging Face Reference)</h1>
59
  <h1>About Text Generation</h1>
60
  <p>