flask – jinja2.exceptions.UndefinedError: ‘predictions’ is undefined

I have a flask website. I was to make prediction images using the model that I build in Google Collab. I have already run it but when I go to the predict pages it seems to get the error ‘jinja2.exceptions.UndefinedError: ‘predictions’ is undefined‘ Can anyone help me. Thank u

The Python Code:

with open('CNN.pth','rb') as file:
    model=torch.load('CNN.pth',map_location='cpu')

classes=('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24')

def predict(filename,model):
    img=load_img(filename,target_size=(32,32))
    img=img_to_array(img)
    img=img.reshape(1,32,32,3)

    img = img.astype('float32')
    img = img/255.0
    result = model.predict(img)

    dict_result = {}
    for i in range(25):
        dict_result(result(0)(i)) = classes(i)

    res = result(0)
    res.sort()
    res = res(::-1)
    prob = res(:3)

    prob_result = ()
    class_result = ()
    for i in range(3):
        prob_result.append((prob(i)*100).round(2))
        class_result.append(dict_result(prob(i)))

    return class_result , prob_result

@app.route('/predict' , methods = ('GET' , 'POST'))
def success():
    error = ''
    target_img = os.path.join(os.getcwd() , 'static/images')
    if request.method == 'POST':
        if (request.files):
            file = request.files('file')
            if file and allowed_file(file.filename):
                file.save(os.path.join(target_img , file.filename))
                img_path = os.path.join(target_img , file.filename)
                img = file.filename

                class_result , prob_result = predict(img_path , model)

                predictions = {
                      "class1":class_result(0),
                        "class2":class_result(1),
                        "class3":class_result(2),
                        "prob1": prob_result(0),
                        "prob2": prob_result(1),
                        "prob3": prob_result(2),
                }

            else:
                error = "Please upload images of jpg , jpeg and png extension only"

            if(len(error) == 0):
                return  render_template('predict.html' , img  = img , predictions = predictions)
            else:
                return render_template('home.html' , error = error)

    else:
        return render_template('home.html')

Index.html

<tr>
                <th>Class</th>
                <th>Probability</th>
            </tr>
            <tr>
              <th>{{predictions.class1}}</th>
                <th>{{predictions.prob1}}</th>
            </tr>
            <tr>
              <th>{{predictions.class2}}</th>
                <th>{{predictions.prob2}}</th>
            </tr>
            <tr>
              <th>{{predictions.class3}}</th>
                <th>{{predictions.prob3}}</th>
            </tr>

Undefined 404’s not logging

Our custom 404 page sends us Emails to notify us of broken links. We’ve been lately getting emails with such a missing page:

http://domain.com/undefined

However, no log entries (IIS) exist on that time with such a request. Further – no log entries exist with the requesting IP (also sent in the email).

What can this mean?

javascript – ¿Por qué luego de la carga de datos en el simulador de costos, los resultados siempre dan undefined?

comunidad. Espero se encuentren bien.
Por acá tengo un simulador de costos el cual al terminar la carga de datos, al realizar el procedimiento, da como “undefined” todos los valores de los resultados. El punto es que no sé por qué esto, creo que será cuando se parsean, pero no salgo de la duda. He probado cambiando elementos en los métodos del objeto y me sigue dando undefined. ¿Podrían ayudarme si son tan amables? Gracias de antemano.

// COSTO MATERIA PRIMA
let costoMaderaXcm = parseFloat(0.15)
let costoTela120Xcm2 = parseFloat(0.342)
let costoTela130Xcm2 = parseFloat(0.438)
// -----------------
alert("A continuación calcularemos el costo de un marco de madera para serigrafia, cuadrado o rectangular, segun la medida de sus lados ingresados en cm y tensado con una tela en 120 o 130 hilos")
class CostoProducto {
    constructor (ladoA, ladoB, trama, precio){
        this.ladoA = parseInt(prompt("Ingrese medida en cm del Lado A"))
        this.ladoB = parseInt(prompt("Ingrese medida en cm del Lado B"))
        this.costoMarco = this.costoMarco
        this.trama = prompt("Ingrese trama: ¿120 o 130?")
        this.costoTela = this.costoTela
        this.costoTotal = this.sumaCostos
    }
    calculoMarco(){
        this.costoMarco = parseFloat(((this.ladoA*2)+(this.ladoB*2))*costoMaderaXcm)
        return(this.costoMarco)
        }   
    calculoTela(){
        if(this.trama == 120){
        this.costoTela = parseFloat((this.ladoA*this.ladoB)*costoTela120Xcm2)
        }
        else{
            this.costoTela = parseFloat((this.ladoA*this.ladoB)*costoTela130Xcm2)
        }
        return(this.costoTela)
        }
    CostoTotal (){
        this.sumaCostos = this.costoTela+this.costoMarco
        return(this.sumaCostos)
    }
}
const CostoProducto1 = new CostoProducto()
CostoProducto1.calculoMarco()
alert("El costo del marco de madera es: "+"$"+this.costoMarco)
CostoProducto1.calculoTela()
alert("El costo de la tela en trama " + this.trama + " es de $"+ this.costoTela)
CostoProducto1.CostoTotal()
alert("El costo total de un marco de "+this.ladoA+"cm X "+this.ladoB+"cm, en trama "+this.trama+" hilos, es de $"+this.sumaCostos)

item is undefined in SharePoint Online but works fine in SharePoint 2013

Long story short I’m migrating SP2013 to SPO. Unfortunately the code is producing an error in the browser console that collListItem is undefined.

All I did was to replace the addresses where needed with the new ones including the imports of jQuery and other resources. The page itself has search functionality which is working fine and a list of letters to pick from (like a dictionary) to check manually for a given word. Upon selecting some of the letters nothing is displayed. After clicking the edit page button all the words are loaded.

I read that this is common issue and the solution was to use SP.SOD.executefunc. Much to my regret this doesn’t seem to work. Last but not least this is just a small excerpt of the code. To keep it tidy I removed the html/css bits and some of the other functions where collListItem is also used but no problems there.

Any suggestions are welcome.

$("#btnSearch").click(function () {
    
    $('#dispRecs').remove();
    $('#nav').remove();
    //$("#spAcronym").text('');
    //$("#spDefinition").text('');
    //$("#spTerm").text('');
    //$("#spDate").text('');
    var txtsTerm = $("#txtSearch").val();
    
    $("#MatchText").empty();
    if($.trim(txtsTerm)!='')
    {
        var letter=$.trim(txtsTerm).substring(0,1);
        $('.aClick').removeClass('aClick');
        $("https://sharepoint.stackexchange.com/#"+ letter).addClass('aClick');
        
        //ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js"); 
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems);
}
else{
$("#MatchText").hide();
$("#noMatchText").hide();
$("#defaultText").show();
$('#alphaSearch').hide();
}

 });
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveautotextItems);
function retrieveautotextItems() {
        var siteUrl = 'https://contoso.com/sites/';
        var clientContext = new SP.ClientContext(siteUrl);
        // Get the list instance
        var oList = clientContext.get_web().get_lists().getByTitle('Term');


        var camlQuery = new SP.CamlQuery();

        var strQuery='';        
        
        strQuery="<View><Query><Where><And><Eq><FieldRef Name='IsActive'/><Value Type='Integer'>"+ "1" +"</Value></Eq><Neq><FieldRef Name='Term'/><Value Type='Text'>"+ "" +"</Value></Neq></And></Where></Query><RowLimit>1000</RowLimit></View>";
        
        //alert(strQuery);
        camlQuery.set_viewXml(strQuery);
        
        this.collListItem = oList.getItems(camlQuery);

        clientContext.load(this.collListItem);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQueryAutoSucceeded), Function.createDelegate(this, this.onQueryAutoFailed));        

    }
    ```

firebase – TypeError: undefined is not an object (evaluating ‘_firebaseConnection.default.db.collection’)

Estou tentando pegar as informações da minha coleção no firebase mais estou recebendo o seguinte erro:

TypeError: undefined is not an object (evaluating ‘_firebaseConnection.default.db.collection’)

esse é meu código do firebase

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
import 'firebase/database';

let firebaseConfig = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: ""

};

if (!firebase.apps.length) {
  firebase.initializeApp(firebaseConfig)
}

const db = firebase.firestore();



export {db}

export default firebase;

o firestore só aparece quando eu coloco:

 const db = firebase.firestore();
  export default {
      firebase,
     db
 };

desse formato acima eu não consigo sair do aplicativo da erro de auth

Código da minha tela de livro aonde o erro ocorre:

const (Libery, setLibery) = useState();

    useEffect(() => {
        firebase.db.collection("biblioteca").onSnapshot((querySnapshot) => {
            const Libery = ();
            querySnapshot.docs.forEach((doc) => {
                const { title, category, uri, pdf } = doc.data();
                Libery.push({
                    id: doc.id,
                    title,
                    category,
                    uri,
                    pdf
                });
            });
            console.log(Libery)
            setLibery(Libery);
        });
    }, ());

sharepoint online – SPFx WebPart started giving TypeError: Cannot read property ‘Content’ of undefined

This webpart was working on a classic Publishing site. Recently, it started throwing this error message:

Error details: Error: Error initializing application. Error: TypeError: Cannot read property ‘Content’ of undefined

When I place this webpart on a modern page, it works without problems but I do not have the luxury to serve it on a modern page. Another strange thing is that it has to be on the rootweb. It does not work under sub webs anymore.(I am thinking something has changed on microsoft recently…)

I can not even debug it because it works in the local workbench and hosted workbench.

Any ideas on how to solve this? or troubleshooting tips?

react native – Cannot read property ‘openCamera’ of undefined android windows

I am currently coding a React Native app that uses a device’s camera with the image crop picker library.

Currently, I’m using Android Studio on Windows to build it, and I keep getting the following error:

Cannot read property ‘openCamera’ of undefined android windows

I tried following the instructions for installation on Android, I got stuck on the step of making edits on the build.gradle file, because there exists many build.gradle files and I don’t know which one the guide was referring to.

I did find the build.gradle file in the react-native-image-crop-picker file in the node-modules directory and I thought making the edits there would solve the problem, but it didn’t.

I tried following the advice found in several threads such as this one:
https://github.com/ivpusic/react-native-image-crop-picker/issues/274

However, they didn’t help me solve the problem.

I wonder if anybody here has an idea how to solve it. I would appreciate it.

spells – Undefined Noise Levels in Booming Blade and Toll the Dead

spells – Undefined Noise Levels in Booming Blade and Toll the Dead – Role-playing Games Stack Exchange

c++ – mingw “undefined reference to” error when compile

i tried to move to minGW to compile my program since i am trying to use a more recent OpenMP version since visual studio uses the 2.0 one, i was planning on using #pragma omp target{} to pass the function for the GPU since it is a rendering part of the code, but now that i am using mingw i cant compile my program anymore, i downloaded the mingw-17.1 to get the needed headers and libs for sdl2.

here is the github for the engine: https://github.com/andrew-lim/sdl2-raycast/

the error i got: https://drive.google.com/file/d/1vavHaADvdj9d5grjZ4YlddV_HlfLUyi-/view?usp=sharing

(i have put the links because the files are too big to write down in a post since it exceeds the characters limit)

When console.logging db results from mongodb undefined is returned

I’m making a Discord Bot with node.js and I’ve managed to get users added to my db but now I can’t get the info back from the db, when I try to do my command a!bal I get object Object back as my message and when I console.log it I get undefined back.

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies 5000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Buy Cheap Private Proxies; Best Quality USA Private Proxies