Ejemplo n.º 1
0
def contact():
    return dbc.Container(
        [
            dbc.Card(
                [
                    dbc.CardBody(
                        [
                            dbc.CardTitle("Norbert Dojer, PhD.", className="text-info"),
                            dbc.CardText(html.P("*****@*****.**")),
                        ]
                    ),
                ],
                outline=True,
                color="info"
            ),
            dbc.Card(
                [
                    dbc.CardBody(
                        [
                            dbc.CardTitle("Paulina Dziadkiewicz, B.Sc.", className="text-info"),
                            dbc.CardText("*****@*****.**"),
                        ]
                    )
                ],
                outline=True,
                color="info",
            )
        ]
    )
Ejemplo n.º 2
0
def page_1_dropdown(value):
    children = []

    if datafr.tempflag == 0:
        if (datafr.steps == 0):
            finals = "Hello"
            finals1 = "Press start to continue..."
            if datafr.temps != finals:
                datafr.temps += finals[datafr.varcount]
                datafr.varcount += 1
            if datafr.temps == finals:
                datafr.varcount = 0
                if datafr.temps1 != finals1:
                    datafr.temps1 += finals1[datafr.varcount1]
                    datafr.varcount1 += 1
                if datafr.temps1 == finals1:
                    datafr.varcont1 = 0
                    datafr.steps += 1

            children = [
                dbc.Card(
                    [
                        dbc.CardBody([
                            dbc.CardTitle(datafr.temps),
                            dbc.CardText(datafr.temps1),
                        ])
                    ],
                    outline=True,
                    color="primary",
                )
            ]
        if (datafr.steps == 1):

            children = [
                dbc.Card(
                    [
                        dbc.CardBody([
                            dbc.CardTitle("Enter Your Name"),
                            dbc.CardText("Hi"),
                            dcc.Link('Go to Page 1', href='/page-1'),
                        ])
                    ],
                    outline=True,
                    color="primary",
                )
            ]

    return children
Ejemplo n.º 3
0
def summary_card(title, value, border_color):
    style = {'border-top': '4px solid ' + border_color}
    header = dbc.CardHeader(
        [html.I(className='fas fa-chart-bar icon-2x'), " " + title],
        style=style)
    body = dbc.CardBody(
        [dbc.CardTitle(str(value), className='text-center', style=CARD_STYLE)])
    return dbc.Card([header, body], color='secondary', inverse=True)
def project_block(project):
    return dbc.Col(
        dbc.Card(
            dbc.CardBody([
                dbc.CardTitle(dcc.Link(children=project.name, href=f"/project/{project.slug}")),
                html.P(f"{len(project.models)} Cell Lines"),
                html.P(f"{project.combinations.count()} Combinations"),
                dcc.Link(f"View Project", className='btn btn-primary shadow-sm',
                         href=f"/project/{project.slug}")
            ]),
            className='shadow-sm mb-4'
        ),
        width=3
    )
Ejemplo n.º 5
0
def display_reddit_posts(n_clicks, subreddit_choice, user_id):
    """
    For the Reddit API, allow the user to specify a subreddit \
    to get data from.

    Args:
        n_clicks (int): Number of times button was clicked.
        subreddit_choice (str): The name of the subreddit.
        user_id (str): Session/user id.

    Returns:
        list: A list of dash components.
    """

    if n_clicks is not None and n_clicks >= 1:
        if subreddit_choice is not None:

            api = pickle.loads(r.get(f"{user_id}_reddit_api_handle"))
            subreddit = api.subreddit(subreddit_choice)

            posts = [
                html.Div([
                    dbc.Card([
                        dbc.CardHeader([
                            html.H4(post.title),
                            html.A("view at reddit", href=post.permalink),
                        ]),
                        dbc.CardBody([
                            dbc.CardTitle(f"Written by {post.author.name}, "
                                          f"score: {post.score}"),
                            dbc.CardText(dcc.Markdown(post.selftext), ),
                        ]),
                    ]),
                    html.Br(),
                ]) for post in subreddit.hot(limit=5)
            ]
            return posts

        else:
            return [html.H4("No subreddit choice")]

    else:
        return [html.H4("No reddit data to display.")]
Ejemplo n.º 6
0
def get_summary(dfs):
    """ Gets a list of h6 with data from previous month """

    mdate = date.today()
    date_m1 = mdate.replace(day=1) - timedelta(days=1)
    date_m2 = date_m1.replace(day=1) - timedelta(days=1)

    # Get stats for last month and the month previous to the last one
    stats = _get_stats(dfs, date_m1)
    stats2 = _get_stats(dfs, date_m2)

    # Header of the summary
    data = [["Stats for months", "{:%Y/%m} ({:%Y/%m})".format(date_m1, date_m2), "secundary"]]

    # Fill the summary with relevant stats
    for name, color in c.colors.COLORS_CARDS.items():
        # bool stating if it is better than previous month (expenses should be reversed)
        aux = stats[name] > stats2[name]
        symbols = ARROWS[not aux if name == c.names.EXPENSES else aux]

        # space as thousand separator
        text = f"{stats[name]:,.0f}€ ({stats2[name]:,.0f}€) {symbols}".replace(",", ".")

        data.append([name, text, color])

    # Show a text with transactions excel file date
    name = get_money_lover_filename()
    data.append(["Using data from", name.split(".")[0].replace("-", "/"), "secundary"])

    return dbc.CardDeck(
        [
            dbc.Card(
                [dbc.CardTitle(title), dbc.CardText(text)],
                color=color,
                className="w3-center",
                style=lay.padding(),
            )
            for title, text, color in data
        ],
        style=lay.padding(),
    )
Ejemplo n.º 7
0
def cartTotalscard(s, e):
    mask = (cart_no['cart_created_date'] > s) & (cart_no['cart_created_date']
                                                 <= e)
    cdf = cart_no[mask]
    cdf_sum = cdf.groupby(['program']).agg({
        'cart_number': 'sum'
    }).reset_index()
    totals =[(i, cdf_sum[cdf_sum['program'] == i].iloc[0]['cart_number']) \
        for i in cdf_sum['program']]
    cards = []
    for x in totals:
        card = \
        dbc.Card(
        [
            # dbc.CardHeader("{}".format(x[0])),
            dbc.CardBody(
                [
                    dbc.CardTitle("{}".format(x[1]), style={'font-size':'2em'}),
                    dbc.CardText("{}".format(x[0].replace("_"," "))),
                ]
            ),
        ])
        cards.append(card)
    return cards
Ejemplo n.º 8
0
         ],
                  style={'text-align': 'center'})
     ]),
             width=4,
             align="center")
 ],
         justify="around",
         className="mb-3"),
 dbc.Row([
     dbc.CardGroup([
         dbc.Card([
             dbc.CardHeader("Number of Tweets",
                            style={'text-align': 'center'}),
             dbc.CardBody([
                 dbc.CardTitle(id="nb_posts",
                               children="0",
                               style={'text-align': 'center'}),
             ]),
         ],
                  color="dark",
                  outline=True),
         dbc.Card([
             dbc.CardHeader("Number of comments",
                            style={'text-align': 'center'}),
             dbc.CardBody([
                 dbc.CardTitle(id="nb_comments",
                               children="0",
                               style={'text-align': 'center'}),
             ]),
         ],
                  color="dark",
Ejemplo n.º 9
0
        'X-Metabase-Session': auth['id']
    }

    card = 'https://metabase.ubiome.io/api/card/{0}/query/json'.format(card_id)
    data = requests.post(card, headers=get_header)
    data_df = pd.DataFrame(data.json())
    return (data_df.to_json(orient='split'))


description = "This dashboard is focused on delivering product analytics for marketing experiments"

topcard = dbc.Card([
    dbc.CardHeader("uBiome Marketing Experiments Dashboard",
                   style={'font_size': '2em'}),
    dbc.CardBody(
        [dbc.CardTitle("How to use"),
         dbc.CardText(dcc.Markdown(description))])
],
                   className="mt-4")
experiment_map = [{
    'exp_name': 'Remove S&H',
    'Product': 'SmartGut',
    'exp_id': 'FOqgdaAZTpmzBv8TH_IHPA'
}, {
    'exp_name': 'Remove S&H',
    'Product': 'SmartJane',
    'exp_id': 'KJ_Up-AXRgWtBqjBbZNkAQ'
}, {
    "exp_name": "Assume Cashpay",
    'Product': 'SmartGut',
    'exp_id': "4zEazw-US3C53kCrBsKw_A"
Ejemplo n.º 10
0
def update_graph_interactive_image(content, number, label, knob,
                                   dictvariables):
    if (content is not None):
        print(content)
        ##        for i in label:
        ##            if i['value']==number:
        ##                dictvariables[label2]=i['label']
        ##        dictvariables[check]=0

        #datafr.loader=0
        #dictvariables[d]=dict()
        #dictvariables[predict]=knob
        #dictvariables[flags1]=1
        img = Image.open('some_image.png')
        print(img)
        number = number
        print('-----------')
        print(dictvariables[0], type(dictvariables[0]))
        dictvariables = ast.literal_eval(dictvariables[0])
        aa = dictvariables[content][0]
        model = build_model(number)
        guided_model = build_guided_model(number)

        modelNamesChoosen = ''
        if number == 1:
            layer_name = 'res5c_branch2c'
            modelNamesChoosen = "ResNet50"
        elif number == 0:
            layer_name = 'block5_conv3'
            modelNamesChoosen = "VGG16"
        elif number == 2:
            layer_name = 'normal_add_2_12'
            modelNamesChoosen = "NasNetMobile"
        elif number == 3:
            layer_name = 'conv_dw_13'
            modelNamesChoosen = "MobileNet"

        gradcam, gb, guided_gradcam, dictionaries = compute_saliency(
            model,
            guided_model,
            layer_name=layer_name,
            img_path=img,
            cls=aa,
            visualize=False,
            save=True,
            string=number,
            knob=knob)

        img1 = ''
        with open("assets/gradcam.jpg", "rb") as imageFile:
            img1 = base64.b64encode(imageFile.read()).decode("utf-8")
        img2 = ''
        with open("assets/guided_backprop.jpg", "rb") as imageFile:
            img2 = base64.b64encode(imageFile.read()).decode("utf-8")
        img3 = ''
        with open("assets/guided_gradcam.jpg", "rb") as imageFile:
            img3 = base64.b64encode(imageFile.read()).decode("utf-8")

        ac = content
        ##        try:
        ##            img_data = open('some_image.png', 'rb').read()
        ##            msg = MIMEMultipart()
        ##            msg['Subject'] = 'Keras Visualtion Tool Report'
        ##            tempstring="The probability predicted by the "+datafr.label2+" model are"+str(datafr.d1)
        ##            text = MIMEText(tempstring)
        ##            msg.attach(text)
        ##            image_data = MIMEImage(img_data, name=os.path.basename('some_image.png'))
        ##            msg.attach(image_data)
        ##            img_data = open('assets/gradcam.png', 'rb').read()
        ##            image_data = MIMEImage(img_data, name=os.path.basename('assets/gradcam.png'))
        ##            msg.attach(image_data)
        ##            img_data = open('assets/guided_backprop.png', 'rb').read()
        ##            image_data = MIMEImage(img_data, name=os.path.basename('assets/guided_backprop.png'))
        ##            msg.attach(image_data)
        ##            img_data = open('assets/guided_gradcam.png', 'rb').read()
        ##            image_data = MIMEImage(img_data, name=os.path.basename('assets/guided_gradcam.png'))
        ##            msg.attach(image_data)
        ##            FROM = "*****@*****.**"
        ##            TO = str(email).split(",")
        ##
        ##            import smtplib
        ##            try:
        ##                server = smtplib.SMTP('smtp.gmail.com', 587)
        ##            except:
        ##                 server = smtplib.SMTP('smtp.gmail.com', 465)
        ##            server.starttls()
        ##            server.login("#youremail", "#yourpassword")
        ##            server.sendmail(FROM, TO, msg.as_string())
        ##            server.quit()
        ##        except Exception as e:
        ##            print('mail error'+str(e))

        ##for firebase no need
        '''
        imageBlob=bucket.blob("gradcam/"+'gradcam_'+datafr.label1+"_"+content+"_"+datafr.new_filename.split(".")[0])
        imageBlob.upload_from_filename('assets/gradcam.jpg')
        imageBlob=bucket.blob("guided_backprop/"+'guided_backprop_'+"_"+datafr.label1+content+"_"+datafr.new_filename.split(".")[0])
        imageBlob.upload_from_filename('assets/guided_backprop.jpg')
        imageBlob=bucket.blob("guided_gradcams/"+'guided_gradcam_'+"_"+datafr.label1+content+"_"+datafr.new_filename.split(".")[0])
        imageBlob.upload_from_filename('assets/guided_gradcam.jpg')

        '''
        ###datafr.loader+=10
        cardgradcam = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Gradcam")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img1))),
                dbc.CardBody([
                    dbc.CardText(ac),
                ]),
            ],
            style={"max-width": "250px"},
        )

        cardprop = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Guided Backpropogation")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img2))),
                dbc.CardBody([
                    dbc.CardText(ac),
                ]),
            ],
            style={"max-width": "250px"},
        )
        cardguided = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Guided Gradcam")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img3))),
                dbc.CardBody([
                    dbc.CardText(ac),
                ]),
            ],
            style={"max-width": "250px"},
        )
        #nnn = ToastNotifier()
        #datafr.loader+=10
        #nnn.show_toast("vizard ", "Task is Completed", duration = 5,
        #icon_path ="assets/favicon.ico")

        #dictvariables[check]=1

        x = []
        y = []
        title = "Probability For " + str(modelNamesChoosen) + " Model"
        for i in dictionaries:
            y.append(i)
            x.append(dictionaries[i][1])
        fig = [
            dcc.Graph(id='example-graph-2',
                      figure={
                          'data': [
                              {
                                  'x': y,
                                  'y': x,
                                  'type': 'bar',
                                  'name': 'Probability'
                              },
                          ],
                          'layout': {
                              'title': title
                          }
                      })
        ]

        return [
            dbc.Card([
                dbc.CardHeader(
                    str(modelNamesChoosen) + " thinks that it is " + ac),
                dbc.CardBody([
                    html.Div([
                        html.Div([
                            html.Div([cardgradcam], className="four columns"),
                            html.Div([cardprop], className="four columns"),
                            html.Div([cardguided], className="four columns"),
                        ],
                                 className="row"),
                    ],
                             className="eleven columns offset-by-one",
                             style={
                                 "margin-top": "10px",
                                 "margin-": "10px"
                             }),
                ]),
            ]),
            html.Div([
                dbc.Card([
                    dbc.CardHeader("vizard \u2b50"),
                    dbc.CardBody([
                        html.Div(fig),
                    ]),
                ]),
            ],
                     style={
                         "margin-top": "10px",
                         "margin-": "10px"
                     }),
        ]

        return [
            html.Div([
                html.Div([cardgradcam]),
                html.Img(src='data:image/jpg;base64,{}'.format(img1)),
                html.Img(src='data:image/jpg;base64,{}'.format(img2)),
                html.Img(src='data:image/jpg;base64,{}'.format(img3)),
            ])
        ]

    else:
        return []

        return [
            html.Div([
                html.Img(src='data:image/jpg;base64,{}'.format(img1)),
                html.Img(src='data:image/jpg;base64,{}'.format(img2)),
                html.Img(src='data:image/jpg;base64,{}'.format(img3)),
            ])
        ]
Ejemplo n.º 11
0
def update_graph_interactive_images(content, new_filename, dictvariables,
                                    number, labels, knob):

    if (content is not None):

        # Base64 string of the input image

        string = content.split(';base64,')[-1]

        imgdata = base64.b64decode(string)

        filename = 'some_image.png'  # I assume you have a way of picking unique filenames

        with open(filename, 'wb') as f:
            f.write(imgdata)

        #image = Image.fromstring('RGB',(200,200),decodestring(string))

    # Do You processing here ----------------

        basewidth = 224
        img = Image.open('some_image.png')
        img = img.convert('RGB')
        wpercent = (basewidth / float(img.size[0]))
        hsize = int((float(img.size[1]) * float(wpercent)))
        datafr.H = 224
        img = img.resize((224, 224), resample=0)
        datafr.W = 224
        img.save('some_image.png')

        number = number
        model = build_model(number)
        guided_model = build_guided_model(number)
        layer_name = ''

        modelNamesChoosen = ''
        if number == 1:
            layer_name = 'res5c_branch2c'
            modelNamesChoosen = "ResNet50"
        elif number == 0:
            layer_name = 'block5_conv3'
            modelNamesChoosen = "VGG16"
        elif number == 2:
            layer_name = 'normal_add_2_12'
            modelNamesChoosen = "NasNetMobile"
        elif number == 3:
            layer_name = 'conv_dw_13'
            modelNamesChoosen = "MobileNet"

        gradcam, gb, guided_gradcam, dictionaries = compute_saliency(
            model,
            guided_model,
            layer_name=layer_name,
            img_path=img,
            cls=-1,
            visualize=False,
            save=True,
            string=number,
            knob=knob)

        img1 = ''
        with open("assets/gradcam.jpg", "rb") as imageFile:
            img1 = base64.b64encode(imageFile.read()).decode("utf-8")
        img2 = ''
        with open("assets/guided_backprop.jpg", "rb") as imageFile:
            img2 = base64.b64encode(imageFile.read()).decode("utf-8")
        img3 = ''
        with open("assets/guided_gradcam.jpg", "rb") as imageFile:
            img3 = base64.b64encode(imageFile.read()).decode("utf-8")

        #print(datafr.d[0][1])
        #ac=str(list(dictvariables[d])[0])
        dictvariables = []
        dictvariables.append(1)
        dictvariables.append(dictionaries)

        ##
        ##        output = open('myfile.pkl', 'wb')
        ##        pickle.dump(dictionaries, output)
        ##        output.close()

        # Manipulate here
        print("Yes1", "\n\n")

        # You can write your python code or call a class/ function of ocr.

        # Your picked image will be stored as some_image.png locally. You can pick this image and manipulate.
        '''

        working example


        img1=''
        with open("some_image.png", "rb") as imageFile:
        img1=base64.b64encode(imageFile.read()).decode("utf-8")

        Now you can send this encoded base64 string to model or convert it into numpy array.


        '''

        ##################################

        ##        img1=''
        ##        with open("some_image.png", "rb") as imageFile:
        ##            img1=base64.b64encode(imageFile.read()).decode("utf-8")

        # Lets say your output text here I'm taking as base64 string of image

        filename = "some_image.png"
        parser = createParser(filename)
        metadata = extractMetadata(parser)
        linestring = []
        counterline = 0
        print("yes2", "\n\n")
        for line in metadata.exportPlaintext():
            if counterline == 0:
                linestring.append(html.Div([html.H5(line)]))
                counterline += 1
            else:
                linestring.append(html.Div([html.P(line)]))

        #datafr.loader+=10
        try:
            linestring = linestring.split("\n")[1:]
            linestring = "\n".join(linestring)
        except:
            pass

        print("YES3.1", "\n\n")
        ac = list(dictionaries)[0]
        print("YES3", "\n\n")

        originalcard = html.Div([
            dbc.Card(
                [
                    dbc.CardBody([dbc.CardTitle(new_filename)]),
                    dbc.CardImg(
                        src=('data:image/png;base64,{}'.format(string))),
                    dbc.CardBody([
                        dbc.CardText(html.P("Original Image")),
                    ]),
                ],
                style={"max-width": "250px"},
            ),
        ],
                                className="twelve columns")

        cardgradcam = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Gradcam")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img1))),
                dbc.CardBody([
                    dbc.CardText(ac),
                ]),
            ],
            style={"max-width": "250px"},
        )

        cardprop = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Guided Backpropogation")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img2))),
                dbc.CardBody([
                    dbc.CardText(ac),
                ]),
            ],
            style={"max-width": "250px"},
        )
        cardguided = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Guided Gradcam")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img3))),
                dbc.CardBody([
                    dbc.CardText(ac),
                ]),
            ],
            style={"max-width": "250px"},
        )

        ##        org=[html.Div([html.Div([dbc.Card([
        ##                dbc.CardHeader("vizard \u2b50"),
        ##                dbc.CardBody(
        ##                    [   html.Div([
        ##                        html.Div([originalcard],className="five columns offset-by-one"),
        ##                        html.Div([
        ##                            html.Div([html.Div(linestring),],className='eight columns'),],className="six columns"),],className='row'),]),
        ##            ])],className="twelve columns"),
        ##            dbc.Card([
        ##                dbc.CardHeader(str(labels)+" thinks that it is "+ ac),
        ##                dbc.CardBody([html.Div([html.Div([
        ##            html.Div([
        ##                cardgradcam
        ##                ],className="four columns"),
        ##            html.Div([
        ##                cardprop
        ##                ],className="four columns"),
        ##            html.Div([
        ##                cardguided
        ##                ],className="four columns"),
        ##            ],className="row"),
        ##                    ],className="eleven columns offset-by-one",style={"margin-top":"10px","margin-bottom":"10px"}),
        ##                         ]),]),
        ##            html.Div([
        ##         dbc.Card(
        ##            [dbc.CardHeader("vizard \u2b50"),
        ##                dbc.CardBody(
        ##                    [html.Div(""),
        ##                    ]
        ##                ),
        ##            ]
        ##        ),],style={"margin-top":"10px","margin-":"10px"})])]
        ##

        print("Library Changed,\n\n")

        #print(org)

        x = []
        y = []
        title = "Probability For " + str(modelNamesChoosen) + " Model"
        for i in dictionaries:
            y.append(i)
            x.append(dictionaries[i][1])
        fig = [
            dcc.Graph(id='example-graph-1',
                      figure={
                          'data': [
                              {
                                  'x': y,
                                  'y': x,
                                  'type': 'bar',
                                  'name': 'Probability'
                              },
                          ],
                          'layout': {
                              'title': title
                          }
                      })
        ]

        return [
            html.Div([
                html.Div(id='lolo',
                         children=[str(dictionaries)],
                         style={'display': 'None'}),
                dbc.Card([
                    dbc.CardHeader("vizard \u2b50"),
                    dbc.CardBody([
                        html.Div([
                            html.Div([originalcard],
                                     className="five columns offset-by-one"),
                            html.Div([
                                html.Div([
                                    html.Div(linestring),
                                ],
                                         className='eight columns'),
                            ],
                                     className="six columns"),
                        ],
                                 className='row'),
                    ]),
                ])
            ],
                     className="twelve columns"),
            dbc.Card([
                dbc.CardHeader(
                    str(modelNamesChoosen) + " thinks that it is " + ac),
                dbc.CardBody([
                    html.Div([
                        html.Div([
                            html.Div([cardgradcam], className="four columns"),
                            html.Div([cardprop], className="four columns"),
                            html.Div([cardguided], className="four columns"),
                        ],
                                 className="row"),
                    ],
                             className="eleven columns offset-by-one",
                             style={
                                 "margin-top": "10px",
                                 "margin-": "10px"
                             }),
                ]),
            ]),
            html.Div([
                dbc.Card([
                    dbc.CardHeader("vizard \u2b50"),
                    dbc.CardBody([
                        html.Div(fig),
                    ]),
                ]),
            ],
                     style={
                         "margin-top": "10px",
                         "margin-": "10px"
                     })
        ]
Ejemplo n.º 12
0
                dbc.DropdownMenuItem("Entry 2"),
                dbc.DropdownMenuItem(divider=True),
                dbc.DropdownMenuItem("Entry 3"),
            ],
        ),
    ],
    brand="Demo",
    brand_href="#",
    sticky="top",
    dark=True,
)

# define content for page 1
page1 = dbc.Card(
    [
        dbc.CardTitle("Page 1 contents"),
        dbc.CardText("You can replace this with whatever you like"),
    ],
    body=True,
)

# define content for page 2

tab1 = dbc.Card(
    [
        dbc.CardTitle("Page 2, tab 1 contents"),
        dbc.CardText("You can replace this with whatever you like"),
    ],
    body=True,
)
Ejemplo n.º 13
0
                ),
    ],
    # mt-4 is margin top 4px
    # vh-100 is view height 100% of window
    className="vh-100 d-flex align-items-center justify-content-center",
)

# About page, brief introduction about the app
about_pg = dbc.Container(
    id='about',
    children=[
        dbc.Row(
            dbc.Card([
                dbc.CardHeader("Holy Grail"),
                dbc.CardBody([
                    dbc.CardTitle("Your skincare recommender app"),
                    dbc.CardText(
                        "Input your favorite product and let Holy Grail recommend other similar products."
                        "You can use the dropdown list to see the recommended products and choose one of them to explore ratings for the products."
                    ),
                ]),
            ]), )
    ],
    className="vh-100 d-flex align-items-center justify-content-center",
)

# start page where users specify their characteristics
start_pg = dbc.Container(
    id='start',
    children=[
        dbc.Row([
Ejemplo n.º 14
0
tab2 = dbc.Card(
    [
        plottab2,
    ],
    body=True,
)
tab3 = dbc.Card(
    [
        plottab3,
    ],
    body=True,
)
tab4 = dbc.Card(
    [
        dbc.CardTitle("Add DataFrame"),
        html.P('DataFrame columns names must be same as given below:'),
        html.P([
            'State/UT, Rape, Kidnapping & Abduction, Dowry Deaths,Assault on women with intent to outrage her modesty,Insult to modesty of women',
            'Cruelty by Husband or his Relatives,Importation of Girls from foreign country, Immoral Traffic (P) Act,Dowry Prohibition Act',
            'Indecent Representation of Women(P) Act, Commission of Sati Prevention Act,Total'
        ]), plottab4,
        html.P("Restart app after uploading.")
    ],
    body=True,
)

caw = dbc.Tabs([
    dbc.Tab(tab1, label="Total C.A.W", className="mt-3"),
    dbc.Tab(tab2, label="States and Sub-Crimes", className="mt-3"),
    dbc.Tab(tab3, label="Crimes Correlation", className="mt-3"),
Ejemplo n.º 15
0
#%% SUMMARY ###################################################################

summary = '''
This dashboard is a part of efforts to standardize operations metrics. 
The focus of this page is to consolidate reporting on carts, orders, and kits.
'''
topcard = dbc.Card([
    dbc.CardHeader("Marketing Key Operations Metrics",
                   style={'font-size': '2em'}),
    dbc.CardBody([
        dbc.Button("Click here to expand more information on this dashboard",
                   id="mko-collapse-button",
                   className="mb-3"),
        dbc.Collapse(
            [
                dbc.CardTitle("UTM Mapping Logic from Growth Marketing"),
                # dbc.CardText(dcc.Markdown(utm_mapping)),
                dbc.CardLink(
                    'Link to Solution Document',
                    href=
                    "https://docs.google.com/document/d/1vg4B9ctNpLSBts4QnnPrnH4iYL2blv4f_IjiU9iZACo/edit"
                )
            ],
            id='mko-collapse',
            is_open=False),
        # dbc.Row(
        #     [
        #         dbc.Col([
        #             # html.H5('Date Selection')
        #             # dcc.DatePickerRange(
        #             #     id='mko-date-picker',
Ejemplo n.º 16
0
def update_graph_interactive_image(content, new_filename):

    if (content is not None):

        string = content.split(';base64,')[-1]
        imgdata = base64.b64decode(string)
        new_filename = new_filename.split(".")[0]
        filename = 'image/' + new_filename + '.png'
        filename1 = 'image/' + new_filename + '.jpeg'  # I assume you have a way of picking unique filenames
        with open(filename, 'wb') as f:
            f.write(imgdata)

        with open(filename1, 'wb') as f:
            f.write(imgdata)

        #image = Image.fromstring('RGB',(200,200),decodestring(string))

    # Do You processing here ----------------

    # Manipulate here

        finaltryfit.mains(new_filename)

        ##################################

        string = ''
        with open("output/im_rec.png", "rb") as imageFile:
            string = base64.b64encode(imageFile.read()).decode("utf-8")

        img1 = ''
        with open("output/output11.png", "rb") as imageFile:
            img1 = base64.b64encode(imageFile.read()).decode("utf-8")

        originalcard = html.Div([
            dbc.Card(
                [
                    dbc.CardBody([dbc.CardTitle(new_filename)]),
                    dbc.CardImg(
                        src=('data:image/png;base64,{}'.format(string))),
                    dbc.CardBody([
                        dbc.CardText(
                            html.P("Image with geometrical coordinates")),
                    ]),
                ],
                style={"max-width": "250px"},
            ),
        ],
                                className="twelve columns")

        VariableOne = dbc.Card(
            [
                dbc.CardBody([dbc.CardTitle("Processed Image")]),
                dbc.CardImg(src=('data:image/jpg;base64,{}'.format(img1))),
                dbc.CardBody([
                    dbc.CardText("Masked Image"),
                ]),
            ],
            style={"max-width": "250px"},
        )

        return [
            html.Div([
                dbc.Card([
                    dbc.CardHeader("Input Image \u2b50"),
                    dbc.CardBody([
                        html.Div([
                            html.Div([originalcard],
                                     className="five columns offset-by-four"),
                        ],
                                 className='row'),
                    ]),
                ])
            ],
                     className="twelve columns"),
            html.Div([
                dbc.Card([
                    dbc.CardHeader("Output Image \u2b50"),
                    dbc.CardBody([
                        html.Div([
                            html.Div([VariableOne],
                                     className="five columns offset-by-four"),
                        ],
                                 className='row'),
                    ]),
                ])
            ],
                     className="twelve columns",
                     style={'margin-bottom': '3%'})
        ]

    else:
        return []
import dash_bootstrap_components as dbc

cards = dbc.Card(
    [
        dbc.CardBody(
            [dbc.CardTitle("Card title"), dbc.CardSubtitle("Card subtitle")]
        ),
        dbc.CardImg(
            src=(
                "https://placeholdit.imgix.net/~text?"
                "txtsize=33&txt=318%C3%97180&w=318&h=180"
            )
        ),
        dbc.CardBody(
            [
                dbc.CardText(
                    "Some quick example text to build on the "
                    "card title and make up the bulk of the "
                    "card's content."
                ),
                dbc.CardLink("A link", href="#"),
                dbc.CardLink("Another link", href="#"),
            ]
        ),
    ],
    style={"max-width": "320px"},
)
Ejemplo n.º 18
0
import dash_bootstrap_components as dbc
import dash_html_components as html

from ..aqa_app import app

# define content for page 1
page1 = dbc.Card(
    [
        dbc.CardTitle("Page 1 contents"),
        dbc.CardText("You can replace this with whatever you like"),
    ],
    body=True,
)

layout = html.Div(page1)
Ejemplo n.º 19
0
    >`owner_id = multikits taken into account, and counted as 1`
***
Use the *Questions? Contact* dropdown for support on the Cash Pay Program or
this Dashboard

__Site Event Analytics can be viewed on the 
[RoadRunner Analytics by Ian Mathew on HEAP](https://heapanalytics.com/app/dashboard/Cashpay-Dashboard-71320)__

__[Checkout Analysis by Doh Jung on Metabase](https://metabase.ubiome.io/dashboard/264?freqeuncy=week)__
'''
topcard = dbc.Card(
    [
        dbc.CardHeader("Cash Pay Program Metrics", style={'font-size':'2em'}),
        dbc.CardBody(
            [
                dbc.CardTitle("How to Use"),
                dbc.CardText(dcc.Markdown(summary))
            ])])

###############################################################################
#### NAVBAR
###############################################################################

# navbar = dbc.NavbarSimple(
#     children=[
#         dbc.NavItem(dbc.NavLink("Dashboard Home", href="#")),
#         dbc.DropdownMenu(
#             nav=True,
#             in_navbar=True,
#             label="Questions? Contact:",
#             children=[
Ejemplo n.º 20
0
        dbc.Col(html.Div("One of three columns", className="bg-secondary p-2 ml-2 rounded-bottom")),
    ], no_gutters=True, className="mt-2"),
    dbc.Row(children=[
        dbc.Col(html.Div("One of 4 columns", className="bg-info p-2 mr-2"), width=3),
        dbc.Col(html.Div("Two of 4 columns", className="bg-info p-2")),
        dbc.Col(html.Div("One of 4 columns", className="bg-info p-2 ml-2"), width=3),
    ], no_gutters=True, className="mt-2"),
    dbc.Row(children=dbc.Col(html.Div("A single, half-width column, width=6", className="bg-secondary p-2"), width=6), className="mt-2"),
    dbc.Row(children=dbc.Col(html.Div("An automatically sized column", className="bg-secondary p-2"), width="auto"), className="mt-2"),

    # 卡片类 ========================================================================================
    html.Div(children=dbc.Row(children=[
        dbc.Col(children=dbc.Card([
            dbc.CardHeader("Header"),
            dbc.CardBody([
                dbc.CardTitle("This card has a title"),
                dbc.CardText("And some text"),
            ]),
        ])),
        dbc.Col(children=dbc.Card([
            dbc.CardBody([
                dbc.CardTitle("This card has a title"),
                dbc.CardText("and some text, but no header"),
            ]),
        ], outline=True, color="primary")),
        dbc.Col(children=dbc.Card([
            dbc.CardBody([
                dbc.CardTitle("This card has a title"),
                dbc.CardText("and some text, and a footer!"),
            ]),
            dbc.CardFooter("Footer"),
Ejemplo n.º 21
0
def render_table(api_choice, user_id):
    """
    Create a display for the chosen dataset.

    Args:
        api_choice (str): Value from the dropdown.
        user_id (str): Session/user id.

    Returns:
        list: A list of dash components.
    """

    if api_choice is None:
        return [html.H4("Nothing selected.")]

    if api_choice == "twitter_api":
        api = pickle.loads(r.get(f"{user_id}_{api_choice}_handle"))

        return pretty_print_tweets(api, 5)

    elif api_choice == "reddit_api":
        # No need to get the api here
        # TODO: But maybe this change?

        return [
            html.H4("Write the name of a subreddit:"),
            dcc.Input(
                id="subreddit_choice",
                type="text",
                value="",
            ),
            html.Button("Gimme dem reddits", id="reddit_submit"),
            html.Br(),
            html.Br(),
            html.Div(id="subreddit_posts"),
        ]

    elif api_choice == "spotify_api":
        spotify = pickle.loads(r.get(f"{user_id}_{api_choice}_handle"))
        top_playlists = spotify.category_playlists(
            "toplists")["playlists"]["items"]

        posts = [
            html.Div([
                dbc.Card([
                    dbc.CardHeader([
                        html.H4(playlist["name"]),
                        html.A("listen on Spotify",
                               href=playlist["external_urls"]["spotify"]),
                    ]),
                    dbc.CardBody([
                        dbc.CardTitle(
                            f"Owner: {playlist['owner']['display_name']}"),
                        dbc.CardText(
                            f"{playlist['tracks']['total']} total tracks"),
                    ]),
                ]),
                html.Br(),
            ]) for playlist in top_playlists
        ]
        return posts

    elif api_choice == "quandl_api":
        df = get_data(api_choice, user_id)

    else:
        df = get_data(api_choice, user_id)

    if df is None:
        return [html.H4("Nothing to display")]

    df = df[df.columns[:10]]
    return [
        html.Br(),
        create_table(df),
    ]
Ejemplo n.º 22
0
import dash_bootstrap_components as dbc

cards = dbc.CardColumns(
    [
        dbc.Card(
            [
                dbc.CardHeader("These cards are arranged in columns"),
                dbc.CardBody(
                    [
                        dbc.CardTitle("This is a title"),
                        dbc.CardText("And some text\nmore text\nmore text"),
                    ]
                ),
            ]
        ),
        dbc.Card(
            [
                dbc.CardHeader("Another card"),
                dbc.CardBody(
                    [
                        dbc.CardTitle("This is a title"),
                        dbc.CardText("And some text"),
                    ]
                ),
            ],
            color="dark",
            inverse=True,
        ),
        dbc.Card(
            [
                dbc.CardHeader("Yet another card"),
def update_facebook_container(n_clicks, value):
    from sentiment.site.data import DataProcess, DataResult
    datapro = DataProcess()
    datares = DataResult(datapro.facebook_convert_searchResult_df(value))

    df_row = datares.get_df_row_count()
    df_original = datares.get_df_original_post()
    likes = datares.get_df_likes_sum()
    df_bow = datares.get_df_features()

    children = [
        dbc.Row([
            dbc.Col(
                dbc.Card(
                    dbc.CardBody([
                        dbc.CardTitle(html.H5('SENTIMENT')),
                        dbc.CardText([
                            dcc.Graph(
                                # FIGURE DONUT GRAPH
                                figure=go.Figure(
                                    data=[
                                        go.Pie(values=[
                                            likes, 5000, 5000, 5000, 5000, 5000
                                        ],
                                               labels=[
                                                   'Like', 'Love', 'Haha',
                                                   'Angry', 'Wow', 'Sad'
                                               ],
                                               hoverinfo='label+percent',
                                               hole=0.4)
                                    ],
                                    layout=go.Layout(margin=go.layout.Margin(
                                        l=40, r=0, t=40, b=30))),
                                style={'height': 300})
                        ])
                    ]))),
            dbc.Col(
                dbc.Card(
                    dbc.CardBody([
                        dbc.CardTitle(html.H5('METRICS')),
                        dbc.CardText([
                            html.H5('CONFUSION MATRIX'),
                            html.H5('CLASSIFICATION REPORT')
                        ])
                    ])))
        ]),
        html.Br(),
        dbc.Row(
            dbc.Col(
                dbc.Card(
                    dbc.CardBody([
                        dbc.CardTitle(html.H5('POSTS ({})'.format(df_row))),
                        dbc.CardText(
                            dashtable.DataTable(
                                data=df_original.to_dict('rows'),
                                columns=[{
                                    'id': i,
                                    'name': i
                                } for i in df_original.columns],
                                style_table={
                                    'maxHeight': 300,
                                    'overflowY': 'scroll'
                                },
                                n_fixed_rows=1,
                                style_cell={
                                    # all three widths are needed
                                    'maxWidth': '100px',
                                    'whiteSpace': 'normal',
                                    'textAlign': 'center',
                                    'padding': '5px'
                                },
                                css=[{
                                    'selector':
                                    '.dash-cell div.dash-cell-value',
                                    'rule':
                                    'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                                }],
                                style_as_list_view=True,
                                style_header={
                                    'fontWeight': 'bold',
                                }))
                    ])))),
        html.Br(),
        dbc.Row(
            dbc.Col(
                dbc.Card(
                    dbc.CardBody([
                        dbc.CardTitle(html.H5('WORD FREQUENCY')),
                        dbc.CardText([
                            dcc.Graph(figure=go.Figure(
                                data=[
                                    go.Bar(x=df_bow.Word,
                                           y=df_bow.Count,
                                           name='Word')
                                ],
                                layout=go.Layout(margin=go.layout.Margin(
                                    l=40, r=0, t=40, b=80))),
                                      style={'height': 300})
                        ])
                    ]))))
    ]

    return children