Spaces:
Runtime error
Runtime error
File size: 4,540 Bytes
7cb9547 |
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 151 152 153 154 155 156 157 158 159 160 161 |
import os
from yattag import Doc
## --------------------------------- ###
### reading: info.txt ###
### -------------------------------- ###
# placeholders in case info.txt does not exist
def get_article(acc, most_imp_feat):
filename = "info.txt"
placeholder = "please create an info.txt to customize this text"
note = "**Note that model accuracy is based on the uploaded data.csv and reflects how well the AI model can give correct recommendations for that dataset. An accuracy of 50% means that half of the model's predictions for that dataset were accurate. Model accuracy and most important feature can be helpful for understanding how the model works, but should not be considered absolute facts about the real world."
title = bkgd = data_collection = priv_cons = bias_cons = img_src = membs = description = placeholder
# check if info.txt is present
if os.path.isfile(filename):
# open info.txt in read mode
info = open(filename, "r")
# read each line to a string
description = "An AI project created by " + info.readline()
title = info.readline()
bkgd = info.readline()
data_collection = info.readline()
priv_cons = info.readline()
bias_cons = info.readline()
img_src = info.readline()
membs = info.readline()
# close file
info.close()
# use yattag library to generate html
doc, tag, text, line = Doc().ttl()
# create html based on info.txt
with tag('div'):
with tag('div', klass='box model-container'):
with tag('div', klass='spacer'):
with tag('div', klass='box model-div'):
line('h2', "Model Accuracy", klass='acc')
line('p', acc)
with tag('div', klass='box model-div'):
line('h2', "Most Important Feature", klass='feat')
line('p', most_imp_feat)
with tag('div', klass='spacer'):
line('p', note)
with tag('div', klass='box'):
line('h2', 'Problem Statement and Research Summary', klass='prj')
line('p', bkgd)
with tag('div', klass='box'):
line('h2', 'Data Collection Plan', klass='data')
line('p', data_collection)
with tag('div', klass='box'):
line('h2', 'Ethical Considerations (Data Privacy and Bias)', klass='ethics')
with tag('ul'):
line('li', priv_cons)
line('li', bias_cons)
with tag('div', klass='box'):
line('h2', 'Our Team', klass='team')
line('p', membs)
doc.stag('img', src=img_src)
css = '''
.box {
border: 2px solid black;
text-align: center;
margin: 10px;
padding: 5%;
}
ul {
display: inline-block;
text-align: left;
}
img {
display: block;
margin: auto;
}
.description {
text-align: center;
}
.panel_button {
display: block !important;
width: 100% !important;
background-color: #00EACD !important;
color: #000;
transition: all .2s ease-out 0s !important;
box-shadow: 0 10px #00AEAB !important;
border-radius: 10px !important;
}
.panel_button:hover {
box-shadow: 0 5px #00AEAB;
transform: translateY(5px);
}
.submit {
color: black !important;
}
.selected {
background-color: #656bd6 !important;
}
.radio_item {
border-radius: 10px;
padding-left: 10px !important;
padding-right: 10px !important;
}
.radio_item:hover {
color: #656bd6 !important;
}
.title {
background-image: url(https://media.giphy.com/media/26BROrSHlmyzzHf3i/giphy.gif);
background-size: cover;
color: transparent;
-moz-background-clip: text;
-webkit-background-clip: text;
text-transform: uppercase;
font-size: 60px;
line-height: .75;
margin: 10px 0;
}
.panel_header {
color: black !important;
}
input {
background-color: #efeffa !important;
}
.acc, .feat {
background-color: #FF3399 !important
}
.prj {
background-color: #FFCE3B !important;
}
.data {
background-color: #ED6800 !important;
}
.ethics {
background-color: #3EE6F9 !important;
}
.team {
background-color: #9581EF !important;
}
.model-container {
display: flex;
flex-direction: column;
justify-content: center;
}
.spacer {
display: flex;
justify-content: center;
}
.model-div {
width: 45%;
}
@media screen and (max-width: 700px) {
.model-container {
flex-wrap: wrap;
}
}
'''
return {
'article': doc.getvalue(),
'css': css,
'title': title,
'description': description,
} |