Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
| 11 |
"""
|
| 12 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 13 |
|
| 14 |
-
# Load model and tokenizer once
|
| 15 |
model = load_model()
|
| 16 |
tokenizer = load_tokenizer()
|
| 17 |
|
|
@@ -40,7 +39,10 @@ def gradio_shap(context):
|
|
| 40 |
plt.tight_layout()
|
| 41 |
return fig
|
| 42 |
except Exception as e:
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
with gr.Blocks() as demo:
|
| 46 |
gr.Markdown("# 🧠 C3QG – Context-Controlled Question Generation with FLAN-T5")
|
|
@@ -62,6 +64,5 @@ with gr.Blocks() as demo:
|
|
| 62 |
inputs=context,
|
| 63 |
outputs=shap_output
|
| 64 |
)
|
| 65 |
-
|
| 66 |
if __name__ == "__main__":
|
| 67 |
demo.launch()
|
|
|
|
| 11 |
"""
|
| 12 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 13 |
|
|
|
|
| 14 |
model = load_model()
|
| 15 |
tokenizer = load_tokenizer()
|
| 16 |
|
|
|
|
| 39 |
plt.tight_layout()
|
| 40 |
return fig
|
| 41 |
except Exception as e:
|
| 42 |
+
fig, ax = plt.subplots(figsize=(8, 2))
|
| 43 |
+
ax.text(0.5, 0.5, f"SHAP explanation failed:\n{e}", ha='center', va='center', wrap=True, fontsize=12)
|
| 44 |
+
ax.axis('off')
|
| 45 |
+
return fig
|
| 46 |
|
| 47 |
with gr.Blocks() as demo:
|
| 48 |
gr.Markdown("# 🧠 C3QG – Context-Controlled Question Generation with FLAN-T5")
|
|
|
|
| 64 |
inputs=context,
|
| 65 |
outputs=shap_output
|
| 66 |
)
|
|
|
|
| 67 |
if __name__ == "__main__":
|
| 68 |
demo.launch()
|