def prediction(image): model = load_model(model_path) img = load_img(image, target_size=(img_height, img_width)) img = img_to_array(img) prediction = model.predict_classes(img) x = labels y = list(prediction) output_file("plots.html") # displaying the image url = str(image) source = ColumnDataSource(data=dict(url=url)) p1 = Figure(x_range=(0, 1), y_range=(0, 1), plot_width=600, plot_height=400) p1.image_url(url='url', x=0, y=1, h=1, w=1, source=source) # plotting the barplot source = ColumnDataSource(data=dict(x=x, y=y, color=Spectral6)) p2 = Figure(x_range=labels, y_range=(0, 1), plot_height=400, plot_width=600, title="Class Probabilites") p2.vbar(x='x', y='y', width=0.9, color='color', legend='x', source=source) # layout grid = gridplot([[p1, p2]]) show(grid)
def _add_image(plot: Figure, image: str): """Add an image to the background of the plot. Args: plot (Figure): Plot to add this image to. image (str): Path to image. """ plot.image_url(url=[image], x=plot.x_range.start, y=plot.y_range.end, w=plot.x_range.end - plot.x_range.start, h=plot.y_range.end - plot.y_range.start, level=IMAGE_LEVEL)
def createBackground(bg_path): # Define plot print "Initializing plot" p = Figure( tools=['xpan'], #¤, _createHoverTool()], width=1587, height=266, x_range=(0, 1527), y_range=(0, 206), min_border=30) # Draw image on background p.image_url(url=[bg_path], x=0, y=206, w=1527, h=207) return p
line_width=2) # this is not currently being used - it is intended to show the image of each system plot2 = Figure(plot_height=800, plot_width=800, x_axis_type=None, y_axis_type=None, tools="pan,reset,save,tap,box_zoom,wheel_zoom", outline_line_color='white', x_range=[-50, 50], y_range=[-50, 50], toolbar_location='right', border_fill_color='white', background_fill_color='white') image1 = 'http://www.stsci.edu/~tumlinso/stark_luvoir_yields/tumlinson-multiplanet_results-12.0_1.00E-10_0.10_3.0/HIP_9829.png' plot2.image_url(url=[image1], x=[-50], y=[50], w=100, h=130) def SelectCallback(attrname, old, new): inds = np.array( new['1d']['indices'] )[0] # this miraculously obtains the index of the slected star within the star_syms CDS star_yield_label.data['labels'] = [str(star_points.data['complete0'][inds])[0:6], \ str(star_points.data['complete1'][inds])[0:6], \ str(star_points.data['complete2'][inds])[0:6], \ str(star_points.data['complete3'][inds])[0:6], \ str(star_points.data['complete4'][inds])[0:6], \ str(star_points.data['complete5'][inds])[0:6], \ str(star_points.data['complete6'][inds])[0:6], \ str(star_points.data['complete7'][inds])[0:6], \ str(star_points.data['complete8'][inds])[0:6], \
) ) # .loc[recdf.index] # print source hover = HoverTool(tooltips=[("Niche Score", "@NicheScore"), ("Price", "@Price")]) # ("Area", "@Neighborhood"), tools = [PanTool(), BoxZoomTool(), WheelZoomTool(), ResetTool(), hover, PreviewSaveTool()] p = Figure(title="NicheLife Map", plot_width=800, plot_height=700, tools=tools) # tools="pan,wheel_zoom,reset,box_zoom,save") # toolbar_location="top", #box_select, p.grid.grid_line_alpha = 0 p.patches("ct_x", "ct_y", source=source, fill_color="QI_colmap", fill_alpha=0.7, line_color="white", line_width=0.5) # image1 = ImageURL(url=source.data["image"], x=-74.04, y=40.85) # p.add_glyph(source, image1) p.image_url(url=imageurl, x="-74.04", y="40.85") # Set up widgets text = TextInput(title="Map Name", value="NicheLife Map") feature1 = Slider(title="Subway Accessibility", value=0.5, start=0, end=1, step=0.1) feature2 = Slider(title="Safety", value=0.5, start=0, end=1, step=0.1) feature3 = Slider(title="Public Satisfaction", value=0.5, start=0, end=1, step=0.1) feature4 = Slider(title="Restaurants", value=0.5, start=0, end=1, step=0.1) feature5 = Slider(title="Grocery Stores", value=0.5, start=0, end=1, step=0.1) feature6 = Slider(title="Nightlife", value=0.5, start=0, end=1, step=0.1) price = Select(title="Show Affordability", options=["Yes", "No"]) # Set up callbacks def update_title(attrname, old, new):
data=dict(x=cluster_xcoords, y=cluster_ycoords, vmax=cluster_vmax, mass=cluster_masses, scatter=scatter_term, \ vmax_up_error=vmax_up_error, vmax_down_error=vmax_down_error)) # Set up plot box_select = BoxSelectTool() plot1 = Figure(plot_height=500, plot_width=770, x_axis_type=None, y_axis_type=None, tools=["pan,reset,tap,wheel_zoom,save", box_select], x_range=[-75, 75], y_range=[-50, 50], toolbar_location='left') plot1.image_url(url=["http://luvoir.stsci.edu/M83.jpeg"], x=[-75], y=[50], w=150, h=100) plot1.x_range = Range1d(-75, 75, bounds=(-75, 75)) plot1.y_range = Range1d(-50, 50, bounds=(-50, 50)) shutters = plot1.square('x', 'y', source=shutter_positions, fill_color='yellow', fill_alpha=0.2, line_color=None, size=20, name="my_shutters") shutters.selection_glyph = Square(fill_alpha=0.5, fill_color="green", line_color='green',