Spaces:
Runtime error
Runtime error
File size: 4,044 Bytes
6b4240d |
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
import torch
import gradio as gr
from utils import *
from torch import nn
import lightning.pytorch as pl
from torch.nn import functional as F
device = 'cuda' if torch.cuda.is_available() else 'cpu'
HTML_TEMPLATE = """
<style>
#app-header {
text-align: center;
background: rgba(255, 255, 255, 0.3); /* Semi-transparent white */
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
position: relative; /* To position the artifacts */
}
#app-header h1 {
color: #FF0000;
font-size: 2em;
margin-bottom: 10px;
}
.concept {
position: relative;
transition: transform 0.3s;
}
.concept:hover {
transform: scale(1.1);
}
.concept img {
width: 100px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.concept-description {
position: absolute;
bottom: -30px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
color: white;
padding: 5px 10px;
border-radius: 5px;
opacity: 0;
transition: opacity 0.3s;
}
.concept:hover .concept-description {
opacity: 1;
}
/* Artifacts */
</style>
<div id="app-header">
<!-- Artifacts -->
<div class="artifact large"></div>
<div class="artifact large"></div>
<div class="artifact large"></div>
<div class="artifact large"></div>
<!-- Content -->
<h1>GPT NEXT WORD GENERATOR</h1>
<p>Generate dialogue for given some initial prompt for context.</p>
<p>Model: GPT, Dataset: arxiv + book + cc, Parameter Count: 160M</p>
"""
with gr.Blocks(theme=gr.themes.Glass(),css=".gradio-container {background: url('file=https://github.com/Delve-ERAV1/Conditional-Diffusion/assets/11761529/1ff9d2e1-798f-442a-a1e2-386fdd35010a')}") as interface:
gr.HTML(value=HTML_TEMPLATE, show_label=False)
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
gr.Markdown("")
with gr.Row():
input_text = gr.Textbox(
label="Input Text",
value="Enter your prompt here: This text will set the context for the AI's response."
)
temperature_dropdown = gr.Slider(0, 1, value=0.8, label="Temperature", info="Set the creativity level: Higher values produce more varied results, lower values generate more predictable text.")
top_k_dropdown = gr.Slider(50, 300, value=200, label="Top K", info="Control the randomness: Limits the AI to consider only the top K most likely next words.")
max_new_tokens = gr.Slider(1, 100, value=50, label="Max Tokens", info="Choose the length: This determines the maximum number of words the AI will generate.")
outputs = gr.Textbox(
label="Generated Dialogue"
)
inputs = [input_text, temperature_dropdown, top_k_dropdown, max_new_tokens]
with gr.Column():
button = gr.Button("Generate")
button.click(generate_dialogue, inputs=inputs, outputs=outputs)
with gr.Row():
gr.Examples(examples=examples, inputs=inputs, outputs=outputs, fn=generate_dialogue, cache_examples=True,)
interface.launch() |